-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot deploy an application using Rails 5.1 Webpacker #25
Comments
This depends on how you installed yarn. Because if you install it standalone, there should be no problem. |
After installing node via nvm, I used: |
When I install yarn globally, using https://yarnpkg.com/lang/en/docs/install/#linux-tab, I get a different error:
Then I imagine I could also install node via ubuntu package, but doesn't this defeat the purpose of using nvm? Thx a lot! |
It seems like you have not the correct version of node installed. What's the output of |
The node version installed as a "user" install is v6.9.5. |
For people having the same issue, this is the workaround we have been using which is not of course not pretty but which does not require to install
|
A better way, as suggested here https://stackoverflow.com/questions/39624035/capistrano-and-api-keys-in-env-variables#answer-39628182 Put your NVM source script in your
|
@olivierpichon You are right! We should add these 3 lines before "if not running interactively". For my ubuntu (Ubuntu 16.04 LTS) it looks like: ~./bashrc
My opinion: capistrano-nvm should solve this problem by itself. But it does not happen. I will check how it implemented on capistano-rvm gem. We should have a workable solution. |
After my investigation, I understood 1 point: we do not have any problems with this gem, we have a problem with assets precompile. assets:precompile is a rake task, not a cap task. |
I created new tasks after investigation: /lib/capistrano/tasks/nvm-webpacker.task
Description:
|
this could be fixed by chaning export NODE_VERSION="v8.2.1" RAILS_ENV="production" RAILS_GROUPS="" ; /tmp/igot/nvm-exec.sh ~/.rvm/bin/rvm ruby-2.3.3@project do bundle exec rake assets:precompile export NODE_VERSION="v8.2.1" RAILS_ENV="production" RAILS_GROUPS="" ; /tmp/igot/nvm-exec.sh ; nvm use $NODE_VERSION ; ~/.rvm/bin/rvm ruby-2.3.3@project do bundle exec rake assets:precompile the key is to run |
Thanks @arevutsky that fixed errors I was having with asset precompilation. I also had to add the wrap/unwrap to DB migration, which apparently also needs the JS runtime. |
Any news on this? Rails 6 is just around the corner and will make webpacker the default (javascript) asset pipeline, so this error is going to be experienced more and more. |
Rails 6 is released now and webpacker is the default asset pipeline, can we fix this please? |
@arevutsky did you have to require that somewhere? running into this issue myself. nvm-webpacker works great... and then gets totally ignored during asset compilation. Edit: nevermind, renamed it to .rake, as Capfile requires all .rake files in lib/capistrano/tasks. Worked like a charm, that should be a PR! |
#25 (comment) is spot on. Without setting up nvm (for capistrano), the error is just the unhelpful |
Ahhh this was so painful to figure out. This: #25 (comment) |
I don't think that this is an issue of this package. Whoever has this issue:
You might also have a problem of shell. If whatever capistrano executes you can execute manually by sshing into the node and calling the command but capistrano fails doing same you might want to check setting correct shell in capistrano |
I updated |
Hours and hours I wasted until I found your comment. Thank you so much sir! |
yarn run v1.22.17 can anybody help me with this? please? |
@abyong123 Did you manage to resolve this? |
This should be on the README file. |
For those still using webpacker and capistrano-nvm. This applied to webpacker 5.4.3 Webpacker enhances rake assets:precompile with yarn:install which eventually calls whatever yarn is in your system's path. The problem is that we're getting at yarn through a rake command issued through capistrano and that is not nvm mapped. So we need rake to be an nvm mapped bin as well. Our solution was to add rake to nvm_map_bins.
This will prefix any rake command issued through capistrano with the nvm-exec.sh script that capistrano-nvm uploads. |
Hi there!
It looks like
capistrano-nvm
is not playing well with Rails 5.1 Webpacker.Rails started make
./bin/yarn
a dependency for assets:precompile here: rails/rails@b1c08d8.bin/yarn
looks like this:As you can see it does a direct system call to
yarnpkg
which is not found in the PATH. I am not sure what's the best way to go around this as Capistrano is not setting environment variables globally but useSSHKit
instead. Any idea?Thx for your help!
The text was updated successfully, but these errors were encountered: