yarn: command not found

Answered

Hi everyone,

I have a new issue since I updated rails gem from 5.2.3 to 6.0.1

When I try to run rails in development mode with the navbar (top right) it just doesn't work, I have the following message :

/usr/bin/ruby /home/flo/Ruby/updatedRailsTest/bin/rails server -b 0.0.0.0 -p 3000 -e development
=> Booting Puma
=> Rails 6.0.1 application starting in development
=> Run `rails server --help` for more startup options
sh: yarn: command not found

========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================


To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).

With some research on similar issue I found that is probably a PATH issue and I tried multiple fix but it doesn't work...

Because if I run "rails s" or "bundle exec rails s" or "yarn" in a normal terminal (or the embeded terminal in bottom of jetbrains IDE) there is no issues, but with the navbar it doesn't work

Best regards

N.B. sorry for my english, i'm french

1
9 comments

Hello Florent,

just to be sure, in case you launch RubyMine from the terminal does it work?

0

Hello,

I launched RubyMine via desktop shortcut (the script run a command like Exec="path_to/rubymine.sh"), but I solved the issue by running "sudo npm i -g yarn" I know that it's not a good practice to install npm package with sudo but for the moment it's ok for me.

 

-1

I have the same problem...

There is another solution?

1

exact same problem...

0
Avatar
Permanently deleted user

Basically normally doing Ruby, I have to use Rails for a project, and face, again, the same kind of weird path issue (I say path cos' it's probably that...)

  • Running the rails app from command line: OK
  • Running the rails app from the embedded terminal within RM: OK
  • Running the rails app from the rails task (execution configuration), having started RM from command line: OK
  • Running the rails app from the rails task (execution configuration), having started RM from launch icon: KO

I did check every possible path coming to my mind within RM (SDK, node, npm/yarn), all of them seem correct.

What can I do to ensure my environment behaves consistently within and outside of RM ?

Olga Kuvardina I see this ticket as being flagged `answered`, but I really do not feel like it is.

--
Build #RM-201.7846.78, built on June 2, 2020

0
Avatar
Permanently deleted user

I think I came to the root of the problem. This is for the Linux version but I guess the issue/resolution is almost the same for other platforms.

First how to solve the issue: You just need to have the node directory in the PATH variable before RM is started... So for me in order to keep the `rubymine.sh` start script untouched to avoid issues when updating, I basically just created a wrapper around to prepend the bin folder of my node installation to the PATH variable, and modified the .desktop file to use that new script instead of the original `rubymine.sh`. As the original `rubymine.sh` uses '/bin/sh' as shell (ie dash on Ubuntu) none of my usual user-level environment variables are set, thus the issue...(including PATH).

So that or any other solution ensuring the path is correctly set before starting RM will fix the issue.

Olga Kuvardina But there is something nevertheless inconsistent in the sense that in RM settings, we explicitly specify the path to where node is actually installed. Thus there should be no need to have it explicitly in the PATH.

Using `/bin/sh` as startup shell sounds pretty sane but then you cannot expect the environment to be the same as the bash/zsh/xxxsh shell the user actually uses, meaning that RM should recreate an environment when executing commands generated from its settings (in that case prepend the path entered in the RM settings for node to the PATH environment variable before executing external commands).

 

1

I don't think this is answered either Olga Kuvardina

So I was using 

- yarn (the latest being 1.22.10)

- node v14.15.1 <- the LTS one

 

Had set up rubymine in what i thought was the correct manner:

 

 

The terminal on Mac works just fine, so does running it on the terminal inside the IDE as mentioned by @...

 

My solution was a bit hacky and definitely NOT the way that i think it should be done.

So instead of using nvm I had to use homebrew to install node and yarn (which effectively keeps 2 copies in the system, one from the nvm shims and another from the homebrew installations) 

So what I did was:

  • brew install yarn <- this installs the latest node version as a dependency which messes up my other dependencies
  • brew uninstall --ignore-dependencies node
  • brew install node@14 <- to give me the LTS version which my project was setup with

honestly don't think that this is the perfect solution because it undermines nvm. But for anyone else facing the problem, until its fixed. This worked.

0

Have the same error

 

I able to run this with my bash script, but it seems that there is no way to change the shell script for Run configuration because it using the user's shell script.

This errors on my machine (Linux Ubuntu) with rvm and zsh.

Still don't know how how to make it working with rvm and zsh. Or at least change to bash for current project (I've changed for /bin/bash for terminal and for Env variables inside Intellij, but it's not helping)

0

Using Ubuntu 20.04 here. I had the same error when using rvm, nvm and zsh for a shell.

Both rvm and nvm were being setup on .zshrc so I moved them to .zshenv and realized they weren't being loaded as per Laurent's comment about Ruby Mine being ran with /bin/sh instead of the user-defined shell.

As /bin/sh reads .profile all I needed to do was to move the contents from .zshenv to .profile and added the following to .zshenv

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"
So .profile looks roughly like the the code block below and it "just works tm"
PATH="$HOME/.rvm/bin:$PATH"
export PATH=$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Dont forget to log out and back in so changes are applied
0

Please sign in to leave a comment.