Heroku deploy fails. So I tried doing it locally same issue.
$ NODE_ENV=production RAILS_ENV=production rails assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke yarn:install (first_time)
** Execute yarn:install
yarn install v1.13.0
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning " > webpack-dev-server#3.3.1" has unmet peer dependency "webpack#^4.0.0".
warning "webpack-dev-server > webpack-dev-middleware#3.6.2" has unmet peer dependency "webpack#^4.0.0".
[4/4] 🔨 Building fresh packages...
✨ Done in 7.99s.
** Execute assets:precompile
I, [2019-04-16T12:10:11.016887 #96897] INFO -- : Writing /private/tmp/template-a32b218/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css
I, [2019-04-16T12:10:11.017485 #96897] INFO -- : Writing /private/tmp/template-a32b218/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz
** Invoke webpacker:compile (first_time)
** Invoke webpacker:verify_install (first_time)
** Invoke webpacker:check_node (first_time)
** Execute webpacker:check_node
** Invoke webpacker:check_yarn (first_time)
** Execute webpacker:check_yarn
** Invoke webpacker:check_binstubs (first_time)
** Execute webpacker:check_binstubs
** Execute webpacker:verify_install
** Invoke environment
** Execute webpacker:compile
Compiling…
Compilation failed:
$ echo $?
1
Webpacker can silently hang if you forgot to do a "yarn add " before actually using a package in your application.
Found the answer to my own question.
In config/webpacker.yml, there's a boolean option to make the output more verbose. And it told me there's was a typo in one of my include statements.
Related
I am using terminal on a macbook air and any command beginning with bundle exec rake db: does't work. I am trying to remove all the tables from my database (aka start from scratch) and them migrate once. Every time I execute any bundle exec rake db: command it just waits a few seconds then stops. Here is a --trace for bundle exec rake db:rollback as an example.
** Invoke db:rollback (first_time)
** Invoke db:environment (first_time)
** Execute db:environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:rollback
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke db:environment
** Invoke db:load_config
** Execute db:schema:dump
I'm attempting to use the application_ruby cookbook to deploy my Rails app on a server Chef is setting up. When the chef-client reaches the point of running bundle install, it crashes, saying that it can't find bundler. I suspect this may have to do with the fact that I'm using RVM on this server, but I'm not sure what to do about that.
Here's my application recipe:
database_name = "app_#{node.chef_environment}"
api_deploy_key = Chef::EncryptedDataBagItem.load('keys', 'app_repository')["deploy_key"]
application "my_app" do
path "/var/www"
owner 'ubuntu'
repository "git#github.com:my_account/app.git"
revision node.chef_environment == "production" ? "master" : "develop"
deploy_key api_deploy_key
rails do
gems [['Bundler', '1.3.4']]
database_master_role 'db_master'
database do
database database_name
username "ubuntu"
password Chef::EncryptedDataBagItem.load('passwords', 'db')["password"]
end
bundler true
precompile_assets true
end
end
And this is the error that it produces:
================================================================================
Error executing action `run` on resource 'execute[bundle install --path=vendor/bundle --deployment --without development test cucumber production]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of bundle install --path=vendor/bundle --deployment --without development test cucumber production ----
STDOUT:
STDERR: /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 175 total gem(s) (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:307:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p125#global/bin/bundle:22:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'
---- End output of bundle install --path=vendor/bundle --deployment --without development test cucumber production ----
Ran bundle install --path=vendor/bundle --deployment --without development test cucumber production returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/application_ruby/providers/rails.rb
86: execute "#{bundle_command} install --path=vendor/bundle #{bundler_deployment ? "--deployment " : ""}--without #{common_groups}" do
87: cwd new_resource.release_path
88: user new_resource.owner
89: environment new_resource.environment
90: end
91: else
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/application_ruby/providers/rails.rb:86:in `block in class_from_file'
execute("bundle install --path=vendor/bundle --deployment --without development test cucumber production") do
action "run"
retries 0
retry_delay 2
command "bundle install --path=vendor/bundle --deployment --without development test cucumber production"
backup 5
cwd "/var/www/releases/30858f319060ca556b5109aa6d0ac64afa3f8e38"
environment {"RAILS_ENV"=>"staging", "PATH"=>"/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"}
returns 0
user "ubuntu"
cookbook_name "my_app"
end
If I set rollback_on_error to false, I can manually go into the checked-out code directory, and run bundle install without problems.
What's going wrong here, and how can I fix it?
you set your environment wrong, it should be:
environment {
"RAILS_ENV"=>"staging",
"PATH"=>"/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games",
"GEM_PATH"=>"/usr/local/rvm/gems/ruby-1.9.3-p125:/usr/local/rvm/gems/ruby-1.9.3-p125#global",
"GEM_HOME"=>"/usr/local/rvm/gems/ruby-1.9.3-p125"
}
I have the following Capistrano snippet:
namespace :bundle do
task :install do
run "gem list && bundle -v"
end
end
When I run
cap bundle:install
I get the following output:
** [out :: ....compute-1.amazonaws.com]
** [out :: ....compute-1.amazonaws.com] *** LOCAL GEMS ***
** [out :: ....compute-1.amazonaws.com]
** [out :: ....compute-1.amazonaws.com]
** [out :: ....compute-1.amazonaws.com] bundler (1.3.4)
** [out :: ....compute-1.amazonaws.com] rake (10.0.3)
** [out :: ....compute-1.amazonaws.com] rubygems-bundler (1.1.1)
** [out :: ....compute-1.amazonaws.com] rvm (1.11.3.6)
** [out :: ....compute-1.amazonaws.com]
** [out :: ....compute-1.amazonaws.com] ERROR: Gem bundler is not installed, run `gem install bundler` first.
gem is showing bundler is installed, but when I try to run bundle -v, I get a contradicting error saying it's not? I don't understand why?
The other thing I tried was to login to the server via terminal, when I run bundle -v there, it works fine?
Any ideas what's wrong?
do you use rvm-capistrano gem? It will load RVM for you.
I managed to get my script working by adding some environment variables:
set :default_environment, {
:PATH => "/home/ubuntu/.rvm/gems/ruby-1.9.2-p320#my_gemset/bin:" +
"/home/ubuntu/.rvm/gems/ruby-1.9.2-p320#global/bin:" +
"/home/ubuntu/.rvm/rubies/ruby-1.9.2-p320/bin:" +
"/home/ubuntu/.rvm/bin:" +
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
:RUBY_VERSION => 'ruby-1.9.2-p320',
:GEM_HOME => '/home/ubuntu/.rvm/gems/ruby-1.9.2-p320#my_gemset',
:GEM_PATH => '/home/ubuntu/.rvm/gems/ruby-1.9.2-p320#my_gemset:/home/ubuntu/.rvm/gems/ruby-1.9.2-p320#global'
}
Capistrano is erroring out on this command
* executing "cd -- /home/root/apps/case/releases/20130221234114 && bundle exec
rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile && cp --
/home/root/apps/case/shared/assets/manifest.yml
/home/root/apps/case/releases/20130221234114/assets_manifest.yml"
and I get this response after it
** [out :: 108.60.137.195] ruby
** [out :: 108.60.137.195] :
** [out :: 108.60.137.195] no -I allowed while running setgid
** [out :: 108.60.137.195] (
** [out :: 108.60.137.195] SecurityError
** [out :: 108.60.137.195] )
Can't seem to find anything related except for a couple of issues with Ruby compiling on macports. I'm using rbenv with Ruby 1.9.3-p385 on Debian 6.
Is it a shared (system-wide) install of rbenv? Old instructions (deleted from wiki as of now, but can be accessed at https://github.com/sstephenson/rbenv/wiki/Shared-install-of-rbenv/a86ef2e6b12254eeb7cecfd3bd878cf7382d1b4a) suggests setting SGID permission bit on Ruby interpreter, which triggers security warnings (and with a good reason).
Current rbenv documentation suggests installing a project-local installation (https://github.com/sstephenson/rbenv/wiki/Deploying-with-rbenv). Alternatively, it could use a system-wide installation without SGID, and using --deployment flag for bundler so that it doesn't try to write to system-wide directories.
My deployment set up is to have Heroku precompile assets. I want them precompiled so I can send them to a CDN (via asset_sync) and I want that done on Heroku so I don't have any compiled assets in my repo. I set that up using Heroku's guide and that had been working great. I added turbo-sprockets-rails3 for a speed boost. It had all been working fine and then stopped; I can't figure out why.
Now when I deploy (without public/assets) the assets:precompile Rake task times out on Heroku. To see how long it's really taking, I went into a shell (heroku run bash):
~ $ time bundle exec rake assets:precompile
AssetSync: YAML file found /app/config/asset_sync.yml settings will be merged into the configuration
AssetSync: Syncing.
Using: Directory Search of /app/public/assets
AssetSync: Done.
real 19m29.575s
user 17m43.690s
sys 0m28.480s
Twenty minutes! But when I run it locally (2011 iMac), it's only only a few minutes:
$ env RAILS_ENV=production time bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
~/.rbenv/versions/1.9.3-p327-perf/bin/ruby ~/.rbenv/versions/1.9.3-p327-perf/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Invoke assets:cache:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
AssetSync: YAML file found ~/Code/Ruby/myproject-rails/config/asset_sync.yml settings will be merged into the configuration
** Execute assets:cache:clean
** Execute assets:precompile:all
AssetSync: Syncing.
Using: Directory Search of ~/Code/Ruby/myproject-rails/public/assets
Uploading: assets/application-3a6de939348195e9610f1321df27837a.js
Uploading: assets/application-3a6de939348195e9610f1321df27837a.js.gz
Uploading: assets/jquery.min-959a5819c76e1508f5a8655c289c0de8.map
Uploading: assets/jquery.min.map
Uploading: assets/rails_admin/rails_admin-76cfbf31a605916a55eee29464ca3e6d.js
Uploading: assets/rails_admin/rails_admin-76cfbf31a605916a55eee29464ca3e6d.js.gz
AssetSync: Done.
179.92 real 19.29 user 3.98 sys
I wrote Heroku support over a week ago and after some days they said they'd escalate it to their Ruby buildback team, but I still haven't heard anything. Do any of the smart people on Stack Overflow have possible solutions?
The solution was to use tell Heroku to use Ruby 1.9.3, like my local machine. Apparently 1.9.3 is much faster at assets compilation than 1.9.2 which Heroku defaults to.
To fix it, make sure your Gemfile starts:
source "https://rubygems.org"
ruby "1.9.3"
# ...
More at Heroku docs on Ruby versions.