Skip to content
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

Failed to read environment variables #2025

Open
ghost opened this issue Aug 16, 2019 · 2 comments
Open

Failed to read environment variables #2025

ghost opened this issue Aug 16, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 16, 2019

I run cap production deploy and got this error:

$HOME/.rbenv/bin/rbenv exec bundle exec rails webpacker:clobber
(Backtrace restricted to imported tasks)
cap aborted!
Errno::ENOENT: No such file or directory - ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" ; $HOME/.rbenv/bin/rbenv exec bundle exec rails webpacker:clobber )

Tasks: TOP => webpacker:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: No such file or directory - ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" ; $HOME/.rbenv/bin/rbenv exec bundle exec rails webpacker:clobber )

This is my deploy.rb file:

lock "~> 3.11.0"

set :application, "myapp"
set :repo_url, "git@github.com:githubusername/myapp.git"

# Deploy to the user's home directory
set :deploy_to, "/home/deploy/#{fetch :application}"

append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'

# Only keep the last 5 releases to save disk space
set :keep_releases, 5

set :default_env, { 
	RBENV_ROOT: "$HOME/.rbenv", 
	RBENV_VERSION: "2.5.5" ,
	RAILS_ENV: "production"
}

before "deploy:assets:precompile", "deploy:yarn_install"

namespace :deploy do
  desc 'Run rake yarn:install'
  task :yarn_install do
    on roles(:web) do
      within release_path do
        execute("cd #{release_path} && yarn install")
      end
    end
  end
end

namespace :env do
  	desc 'Print enviroment variables'
  	task :env do
	  on roles(:all) do
	    execute "env"
	  end
	end
end

after 'deploy:updated', 'webpacker:precompile'

I also have a file in server /home/deploy/myapp/.rbenv and /home/deploy/myapp/.rbenv-vars that contain:

RAILS_MASTER_KEY=ohai
SECRET_KEY_BASE=1234567890

STRIPE_PUBLIC_KEY=x
STRIPE_PRIVATE_KEY=y

RBENV_ROOT=.rbenv
RBENV_VERSION=2.5.5
RAILS_ENV=production

What is the solution?

@leehambley
Copy link
Member

Tasks: TOP => webpacker:precompile isn't provided by https://github.com/capistrano/capistrano and seems to be doing the wrong thing when using "advanced" settinghs as you are doing.

The message indicates that they are trying to execute a "string" when they should be trying to execute an array of arguments, I think, but this isn't a https://github.com/capistrano/capistrano problem, I'm quite sure.

I'll leave this issue open whilst you report upstream to your webpacker:precompile vendor, you can link them this ticket.

@ghost
Copy link
Author

ghost commented Aug 16, 2019

Yeah fixed. tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant