Skip to content

Commit 44f98fe

Browse files
authored
Update deployment.md to reflect nvm usage (#2755)
When trying to deploy to a user that uses nvm instead of the system version of nodejs, Capistrano will fail to find the node executable. This commit resolves this by adding a call to the nvm loading script before running yarn in the execute line.
1 parent d2cb1f4 commit 44f98fe

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/deployment.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,21 @@ namespace :deploy do
128128
end
129129
end
130130
```
131+
132+
If you use [nvm](https://github.com/nvm-sh/nvm) to manage node versions for your deployment user, use the below snippet instead:
133+
134+
```ruby
135+
before "deploy:assets:precompile", "deploy:yarn_install"
136+
namespace :deploy do
137+
desc "Run rake yarn install"
138+
task :yarn_install do
139+
on roles(:web) do
140+
within release_path do
141+
execute("source ~/.nvm/nvm.sh && cd #{release_path} && yarn install --silent --no-progress --no-audit --no-optional")
142+
end
143+
end
144+
end
145+
end
146+
```
147+
The `source ~/.nvm/nvm.sh` is required because [nvm is not automatically loaded in non-interactive shells](https://github.com/nvm-sh/nvm/issues/1718).
148+

0 commit comments

Comments
 (0)