zpm-zsh/autoenv

check_and_run:8: permission denied

maturanomx opened this issue ยท 14 comments

This is my .env file (similar as the example on README for NodeJS):

nvm use node
OLDPATH=$PATH
export PATH=`pwd`/node_modules/.bin:$PATH

When I enter to the directory I got the error this error:

> WARNING
> This is the first time you are about to source "/tmp/test/.env"

----------------

check_and_run:8: permission denied:

----------------

Are you sure you want to allow this? (y/N) y
N/A: version "N/A" is not yet installed.

You need to run "nvm install N/A" to install it before using it.

However, I'm able to source it without problem.
screen shot 2018-03-27 at 7 07 11 pm

I don't have idea why ๐Ÿ˜•.

Version: zsh 5.4.2 (x86_64-apple-darwin17.3.0)

Mmm.. Very intresting

Please run check_and_run .env from directory /tmp/test and show me output.

Also create a simple file .env

echo it works

in your home directory and open new zsh session.

Interesting ๐Ÿค” ...

With the .env on home I have the same permission denied message, but the scrips is executed.

grep: /Users/maturano/.autoenv_authorized: No such file or directory
> WARNING
> This is the first time you are about to source "/Users/maturano/.env"

----------------

check_and_run:8: permission denied:

----------------

Are you sure you want to allow this? (y/N) y
it works

Running check_and_run .env manually run as expected (Note: I also try with the absolute path and works):

> WARNING
> This is the first time you are about to source ".env"

----------------

nvm use node
OLDPATH=$PATH
export PATH=`pwd`/node_modules/.bin:$PATH

----------------

Are you sure you want to allow this? (y/N) y
Now using node v8.10.0 (npm v5.6.0)

screen shot 2018-03-28 at 10 51 04 am

Line 8 in function check_and_run contain whence pygmentize, please execute it and show output. Also check if you have env variable $COLORS, execute echo $COLORS

whence pygmentize
echo $COLORS
$ whence pygmentize
/usr/local/bin/pygmentize

$ echo $COLORS
true

To be honest, I don't know where (and why) $COLORS is set ๐Ÿค”


screen shot 2018-04-02 at 5 47 18 pm


EDIT: Add information.

  1. I can execute pygmentize from command line without problem.

  2. Set $COLORS to false avoid the title error, but nvm still not working ๐Ÿ˜•

screen shot 2018-04-02 at 6 19 59 pm

5d5cce0 commit is what introduce this behaviour. Before that, works.

Maybe @ithinuel could help us here ๐Ÿ˜‡


EDIT: Correction... almost work. It is executing two times (on commit f535246)
screen shot 2018-04-02 at 6 57 45 pm

I already have 2 issues with this commit. I temporarily revert repository in initial state

Please update plugin.

Hi, the error N/A: version "N/A" is not yet installed don't seem to be related to this as you invoke nvm use stable.
I'd say there's something else going on here.

I reproduced your issue (I was missing pygmentize).
I'm able to fix it by removing "whence" and calling pygmentize directly.

@horosgrisa what is this whence for here ?

@ithinuel

Hi, the error N/A: version "N/A" is not yet installed don't seem to be related to this as you invoke nvm use stable.
I'd say there's something else going on here.

The thing is, changes on this repository affect that behaviour. I'm able to source the .env and works fine. That's the behaviour that I expect of this plugin: just source the file in an automatic way.

By the error message I imagine is due to an environment change and it looks to me is pretty related to the "permission" error. Maybe create a sub-shell, sub-process... I don't know to be honest ๐Ÿ˜…

@horosgrisa
Right now from master, nvm is able to run:
screen shot 2018-04-03 at 10 20 10 am

It is executed two times. Should we create other ticket for that? Is that was 5d5cce0 tried to solve? ๐Ÿค”

it was to solve #14 and later #15 and a couple other unreported issues.
I have this "double source" issue when I source the plugin for update.
The safe way is to close the terminal and open a new one.

What happens if you apply this patch

diff --git a/autoenv.plugin.zsh b/autoenv.plugin.zsh
index 1b8ed9b..8a321dc 100755
--- a/autoenv.plugin.zsh
+++ b/autoenv.plugin.zsh
@@ -25,7 +25,7 @@ check_and_run(){
     echo -e "$fg_no_bold[green]----------------$reset_color"
     if hash pygmentize 2>/dev/null; then
       echo
-      `whence pygmentize` -f 256 -l shell -g "$1"
+      pygmentize -f 256 -l shell -g "$1"
     else
       echo -e "$fg_no_bold[green]"
       cat $1

to 86c9835 ?

Does-it solve your issue ?

I reverted revert.

The "N/A" error apparently was a nvm issue. I updated it and works all now ๐Ÿคฆโ€โ™‚๏ธ .

I'll close this issue. Thanks for everything ๐Ÿ‘

@maturano That's a good news !
@horosgrisa Could you please restore master to this commit id : 86c9835 where the PR #16 was actually merged :) (this will have the bonus of keeping a nice history)
The following commands should do the trick :

git checkout master
git rebase 86c98355ac28c93d92202d4fd9eea8036e6c9dcf 
git push -f

EDIT: Actually no, let me find a solution โš”๏ธ
there we go :

git stash -u
git checkout master
git remote add ithinuel git@github.com:ithinuel/autoenv.git
git fetch ithinuel
git reset --hard 86c98355ac28c93d92202d4fd9eea8036e6c9dcf
git push -f