Open mileslucas opened 4 years ago
Apologies for this. I believe you're following the instructions prefixed by:
Optionally, try to compile dynamic bash extension to speed up jlenv. Don’t worry if it fails; jlenv will still work normally
Which makes the docker/Ubuntu a bug. I'll look into this.
The zsh error may just be because of a bash-ism? I don't use zsh, so any patches you can suggest to allow this to run on both would be appreciated.
@mileslucas Just to be clear: Did you complete step 2) before step 3)?
There is a documentation bug because the path setup requirement/step is not mentioned in the preceding section If that still does not work for you....
When you get a minute, can you paste the output from this command:
JLENV_DEBUG=1 bin/jlenv init
If you're keen: Can you try to run the following, you will need to install bats:
$ bats --tap test/init.bats
/home/<user>/src/jlenv/test/libs/bats /home/<user>/src/jlenv
Installed Bats to /home/<user>/src/jlenv/test/libexec/bin/bats
/home/<user>/src/jlenv
1..14
ok 1 creates shims and versions directories
ok 2 auto rehash
/home/<user>/src/jlenv/test/libs/bats /home/<user>/src/jlenv
Installed Bats to /home/<user>/src/jlenv/test/libexec/bin/bats
/home/<user>/src/jlenv
1..14
ok 1 creates shims and versions directories
ok 2 auto rehash
ok 3 setup shell completions
ok 4 detect parent shell
ok 5 detect parent shell from script
ok 6 setup shell completions (fish)
ok 7 fish instructions
ok 8 option to skip rehash
ok 9 adds shims to PATH
ok 10 adds shims to PATH (fish)
ok 11 can add shims to PATH more than once
ok 12 can add shims to PATH more than once (fish)
ok 13 outputs sh-compatible syntax
ok 14 outputs fish-specific syntax (fish)
@taqtiqa-mark
The problem is not necessarily the init
function itself; it's actually the jlenv
main script.
Regardless of path issues, I always get a syntax error when trying to run bin/jlenv
or libexec/jlenv
$ JLENV_DEBUG=1 bin/jlenv init
bin/jlenv: line 638: syntax error near unexpected token `;;'
$ JLENV_DEBUG=1 bin/jlenv versions
bin/jlenv: line 638: syntax error near unexpected token `;;'
$ JLENV_DEBUG=1 libexec/jlenv help
libexec/jlenv: line 638: syntax error near unexpected token `;;'
If I run the libexec/jlenv
through shellcheck it doesn't report syntax errors.
Here is my BATS run
$ bats --tap test/init.bats
bats: /Users/miles/.jlenv/test/libs/bats-support/load.bash does not exist
If I understand correctly your shell is zsh? Can you report your version of zsh, that way we can track the cause if anyone else reports this.
If so then the unexpected token
;;'` is very likely a zsh issue, because we saw it didn't occur with the Docker/Ubuntu run - which uses bas by default (actually this is depending when a script is run - I think it will also (it used to) use dash in the early stages of a boot).
I think you'll find things work in Docker/Ubuntu when you add <folder>/bin/jlenv
to your path before running bin/jlenv init
.
The missing test/libs
is a separate issue tracked here #19 .
@mileslucas apologies for the incomplete instruction - been a while sine I had my head in this code.
For the tests to run please do this:
# this will install test scaffolding then run the full test suite
test/run
We expect you'll see errors based on your report so far.
If you do please report only the unexpected token
;;'` errors to this issue.
As you say shell check and bash like the script so its not clear what is up with zsh.
ZSH_VERSION=5.7.1
Bats output now is
$ bats --tap test/init.bats
/Users/miles/.jlenv/test/libs/bats /Users/miles/.jlenv
Installed Bats to /Users/miles/.jlenv/test/libexec/bin/bats
/Users/miles/.jlenv
1..14
ok 1 creates shims and versions directories
ok 2 auto rehash
ok 3 setup shell completions
ok 4 detect parent shell
ok 5 detect parent shell from script
ok 6 setup shell completions (fish)
ok 7 fish instructions
ok 8 option to skip rehash
ok 9 adds shims to PATH
ok 10 adds shims to PATH (fish)
ok 11 can add shims to PATH more than once
ok 12 can add shims to PATH more than once (fish)
ok 13 outputs sh-compatible syntax
ok 14 outputs fish-specific syntax (fish)
I note that since jlenv
begins with #!/usr/bin/env bash
it is being run with bash. This can be corroborated by still seeing the syntax error when running explicitly bash bin/jlenv
.
Hmm, OK so how do the bash in the Docker/Ubuntu you ran and the Bash on your sytem differ?
You can check the versions of bash I currently test against here. At the moment - in that dev area - any bash older than 4.3 is expected to fail.
This might be the case here? I appreciate this can be frustrating, which is why I spent the effort setting up the more elaborate Travis test suite - to eliminate the version of bash as possible cause of subtle issues just like this.
Yes, my bash version is 3.2.57(1)-release
I upgraded with
$ brew install bash
which set me up with 5.0.11(1)-release
This still does not work with
$ PATH=$HOME/.jlenv/bin:$PATH bin/jlenv init
jlenv: No such command: $(init)
but
libexec/jlenv init
works fine.
If the bash version is an expected failure and not planned to be fixed, I'm fine closing this issue.
I would add a note in the README, though, about this. The default version for Mac OS X is the old 3.x version, so I would consider this a typical failure. In the future, when jlenv
inevitably gets set up with a homebrew formula, I suggest pinning the minimum bash version as a dependency so theoretically $ brew install jlenv
JustWorks^TM
Thanks for persevering with this.
Does the following work for you?
PATH=$HOME/.jlenv/bin:$HOME/.jlenv/libexec:$PATH bin/jlenv init
Yes, adding the libexec path to PATH
fixes everything.
OK, so to summarise:
unexpected token ;;
: due to bash version <4.3I'll change the issue description and keep this open.
I cannot install jlenv
System 1: Mac OS X Catalina Zsh
System 2: Docker ubuntu