purescript-contrib / pulp

A build tool for PureScript projects
GNU Lesser General Public License v3.0
445 stars 86 forks source link

Unable to run pulp init using volta which shims purs into my path #386

Closed Samsinite closed 5 years ago

Samsinite commented 5 years ago

A little background incase you are unfamiliar with Volta. Volta is a node and JavaScript command-line tools version manager. After installing purescript, bower, and pulp via volta, running pulp init fails:

Samuels-MacBook-Pro:chapter-three samueljclopton$ volta install purescript bower pulp
Package purescript@0.13.3 is already installed
Package bower@1.8.8 is already installed
Package pulp@13.0.0 is already installed
Samuels-MacBook-Pro:chapter-three samueljclopton$ pulp init
* ERROR: `purs` executable not found.

Not sure if this issue belongs here or inside of the volta respository.

Samsinite commented 5 years ago

Looking at my path, this seems like an issue with pulp being unable to handle a shim to run purs:

Samuels-MacBook-Pro:chapter-three samueljclopton$ echo $PATH
/Users/samueljclopton/.volta/bin:/Users/samueljclopton/.cargo/bin:/Users/samueljclopton/.rbenv/shims:/usr/local/opt/openssl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/Users/samueljclopton/Library/Android/sdk/tools:/Users/samueljclopton/Library/Android/sdk/tools/bin:/Users/samueljclopton/Library/Android/sdk/platform-tools:/Users/samueljclopton/Library/Android/sdk/tools:/Users/samueljclopton/bin:/Applications/Postgres.app/Contents/Versions/10/bin

Then printing the path of the volta shims:

Samuels-MacBook-Pro:chapter-three samueljclopton$ ls -la /Users/samueljclopton/.volta/bin
total 0
drwxr-xr-x  10 samueljclopton  staff  320 Sep 18 13:03 .
drwxr-xr-x  11 samueljclopton  staff  352 Sep 18 13:03 ..
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 bower -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 ember -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 node -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 npm -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 npx -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 pulp -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 purs -> /Users/samueljclopton/.volta/shim
lrwxr-xr-x   1 samueljclopton  staff   33 Sep 18 13:03 yarn -> /Users/samueljclopton/.volta/shim
hdgarrood commented 5 years ago

Pulp isn't doing anything weird here, it just uses the purs it finds on your PATH. I'm not sure why it isn't working. pulp init works for me when the first purs in my path is a symbolic link which points to the actual executable. Can you maybe try to find out what it is about the shim which is breaking this?

Samsinite commented 5 years ago

Installing the purs binary in my path instead of through worked once I symlink'd to bower ahead of the volta shim in my path. Seems like an error with pulp not recognizing a shim'd binary named bower and purs already in my path (which calls the designated purs/bower binary based off of package.json priorities).

Samsinite commented 5 years ago

@hdgarrood If you take a closer look at https://github.com/purescript-contrib/pulp/issues/386#issuecomment-532845651, then you can see that it isn't using the purs binary in my path.

hdgarrood commented 5 years ago

Yes, I can see that, but I want to understand what is different about your setup; pulp does use the purs in my PATH, even when that purs is a symbolic link.

Samsinite commented 5 years ago

The difference is that purs is symlinked to the executable /Users/samueljclopton/.volta/shim which calls the correct purs version based off of its resoltion algorithm.

hdgarrood commented 5 years ago

What I'm really asking is can you come up with a repro case which doesn't involve volta.

Samsinite commented 5 years ago

Hmm... I think this is a volta issue then, it seems to work when I install a simple bash shim: purs

#!/bin/bash

/Users/samueljclopton/.volta/tools/image/packages/purescript/0.13.3/purs.bin "$@"
Samsinite commented 5 years ago

I'll close and open an issue there, thanks for the help!

hdgarrood commented 5 years ago

Good luck, sorry I couldn't be of more help.

Samsinite commented 5 years ago

No worries, a direct symlink will work for now until volta can fix it :)