volta icon indicating copy to clipboard operation
volta copied to clipboard

Volta fails to set executable for node/yarn on Mac OS

Open kingscott opened this issue 7 years ago • 19 comments

It seems that install volta when using a fish shell, the executables do not get properly set. Therefore, my system version is either non-existent or it uses a version from a previous workflow.

As a temporary work around, I copied the executables found in ~/.volta/bin/ to /usr/local/bin/. But this breaks down when using volta for multiple projects, with different versions.

kingscott avatar Sep 24 '19 16:09 kingscott

@kingscott thanks for reporting this. Can you provide specific steps to reproduce? I wrote the fish installation setup (because I needed it for myself!) and use it regularly.

chriskrycho avatar Oct 01 '19 14:10 chriskrycho

Hey @chriskrycho, sure thing!

I installed volta via the instructions found here. And then I'd install a version of node, for example:

$  volta install node

...but it didn't populate the executable node command that I expected in my terminal. I ran it a few different times, and opened new fish sessions, but nothing. :/

As mentioned, I had to manually copy the executable to the /usr/local/bin folder.

Edit: I don't think volta install node@stable actually works, but I did [email protected] (which is the latest stable).

kingscott avatar Oct 02 '19 14:10 kingscott

Huh! What OS and OS version, and what fish version, are you using?

chriskrycho avatar Oct 02 '19 15:10 chriskrycho

Fish: 3.0.2 MacOS: 10.14.15

kingscott avatar Oct 02 '19 15:10 kingscott

It seems that ~/.volta/load.fish just needs to be added to ~/.fish/functions/volta.fish and then executed in the config.fish file and everything works properly.

Maybe I'm wrong here, but could I tackle this if it's the case? @chriskrycho

kingscott avatar Oct 15 '19 00:10 kingscott

🤔 I find your description of the situation pretty confusing (not at all meaning you're describing it badly!). What is your PATH defined as? (I'm happy to support your doing the work to fix it, I just want to make sure we actually understand the problem correctly first!).

chriskrycho avatar Oct 16 '19 00:10 chriskrycho

Here's what I'm experiencing on a fresh install

volta

kingscott avatar Oct 21 '19 13:10 kingscott

Yep, that makes sense given your write up. Thanks! Can you share the Volta-specific contents of your fish config and the output of echo $PATH?

chriskrycho avatar Oct 21 '19 13:10 chriskrycho

For my volta-specific additions to my fish config, it is just the code found in ~/.volta/load.fish:

function volta
    # Use the user's existing `VOLTA_HOME` environment value if set; otherwise,
    # use a default of `~/.volta`.
    if set -q VOLTA_HOME;
        set VOLTA_ROOT "$VOLTA_HOME"
    else
        set VOLTA_ROOT "$HOME/.volta"
    end

    # Generate 32 bits of randomness, to avoid clashing with concurrent executions.
    set -x VOLTA_POSTSCRIPT "$VOLTA_ROOT/tmp/volta_tmp_"(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")".fish"

    # Forward the arguments to the Volta executable.
    env VOLTA_SHELL=fish "$VOLTA_ROOT/volta" $argv
    set EXIT_CODE $status

    # Call the post-invocation script if it is present, then delete it.
    # This allows the invocation to potentially modify the caller's environment (e.g., PATH).
    if test -f "$VOLTA_POSTSCRIPT"
        source $VOLTA_POSTSCRIPT
        rm "$VOLTA_POSTSCRIPT"
    end

    set -e VOLTA_POSTSCRIPT
    return $EXIT_CODE
end

And here is my echo $PATH output:

/Users/kingscott/.rvm/gems/ruby-2.3.0/bin /Users/kingscott/.rvm/gems/ruby-2.3.0@global/bin /Users/kingscott/.rvm/rubies/ruby-2.3.0/bin /Users/kingscott/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

kingscott avatar Oct 23 '19 15:10 kingscott

So, you're missing the relevant Volta entries on your PATH, as I expected, and this is because your fish.config is missing the bits the installer normally adds. 🤔

Can you remove the contents of ~/.volta/load.fish from your fish.config and re-run the installer? The installer normally just sets up your PATH and adds a hook to run load.fish, but if it finds references to Volta already present, it skips that action.

chriskrycho avatar Oct 23 '19 15:10 chriskrycho

Steps followed:

  • Remove ~/.volta directory
  • Remove volta function from my fish config
  • Remove any other leftovers from volta
  • Ran the documented command to install volta via CLI

My path:

/Users/kingscott/.rvm/gems/ruby-2.3.0/bin /Users/kingscott/.rvm/gems/ruby-2.3.0@global/bin /Users/kingscott/.rvm/rubies/ruby-2.3.0/bin /Users/kingscott/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

And volta is not defined.

kingscott avatar Oct 25 '19 15:10 kingscott

Thanks! What if anything does your fish config have now?

chriskrycho avatar Oct 25 '19 15:10 chriskrycho

It has nothing at the moment.

[And if I want to get things working again, I just copy the contents of ~/.volta/load.fish into my fish.config]

kingscott avatar Oct 25 '19 15:10 kingscott

That’s helpful, thanks! One of us will try to see what changed/broke in the installer!

chriskrycho avatar Oct 25 '19 15:10 chriskrycho

FWIW, we think the problem is how the installer is identifying which profile to use! @charlespierce has an idea for how to solve it; in the meantime, there are two solutions:

  1. (Simplest option) When installing, run:

    $ curl https://get.volta.sh | env PROFILE=$HOME/.config/fish/config.fish bash
    

    This should set up your profile correctly.

  2. (Manual option) Instead of copying load.fish into your shell directly, copy what we are currently failing to install into your config:

    set -gx VOLTA_HOME "$HOME/.volta"
    test -s "$VOLTA_HOME/load.fish"; and source "$VOLTA_HOME/load.fish"
    

chriskrycho avatar Oct 31 '19 16:10 chriskrycho

I experienced something similar, when switching to fish from zsh, the installer seems to get confused. On the first go, it did nothing so i wiped out ~/.volta, but after that the installer tried to modify .zshrc. Running env PROFILE=$HOME/.config/fish/config.fish before the installer seemed to do the trick.

thousand avatar Oct 31 '19 16:10 thousand

@chriskrycho Note volta-install is an internal copy of the install script. In general that should be:

$ curl https://get.volta.sh | env PROFILE=$HOME/.config/fish/config.fish bash

charlespierce avatar Oct 31 '19 16:10 charlespierce

Excellent point; updated!

chriskrycho avatar Oct 31 '19 16:10 chriskrycho

I believe with the updated installer / volta setup logic, this should no longer be an issue. We now will install into any / all shell configurations that we find, instead of just the first. Feel free to re-open if there are still installation issues on Fish.

charlespierce avatar Jun 11 '20 00:06 charlespierce