Error when trying precompile assets, getting yarn error with rails - ruby-on-rails

rails -v: Rails 6.1.0
ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]
I'm having this error when I try to run rails assets:precompile
rails aborted!
Errno::ENOEXEC: Exec format error - C:/Users/trynot/Desktop/prolife/bin/yarn --version
Tasks: TOP => assets:precompile => yarn:install
(See full trace by running task with --trace)
What I've tried:
I already uninstalled and reinstalled all my gems, tried to update all my gems, tried to generate a new project with the flags --skip-webpack-install, tried removing the file yarn from bin, and tried to reinstall yarn. Same problem!

This issue is resolved on this commit https://github.com/rails/rails/commit/5c8805034f5f59b7278f895fca7b6fd7dfda7af5#diff-7c64b5585b553fe2873f6b3cee2675a6d63997f3c7af82ccf23c1073773c40d3

Related

Heroku rails pg_ext.so LoadError

I am trying to deploy my rails app to Heroku. I've created an app and successfully pushed it, but when i do
heroku run rake db:migrate
i am getting this error
> rake aborted!
> LoadError: libruby.so.2.3: cannot open shared object file: No such file or directory -
> /app/vendor/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg_ext.so
Rails 5.0.4
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
pg-0.21.0
I've seen similar posts and tried to apply described solutions, but no luck. Tried other versions of pg like here Cannot migrate on Heroku
But it didn't help.
Thanks.
Try purging Heroku dyno's cache:
heroku plugins:install https://github.com/heroku/heroku-repo.git
heroku repo:purge_cache -a appname

Rails app cant right see the version of Ruby so I cant migrate db

Local installed Ruby 2.0.0, but app think that installed 1.9.3 version:
# bundle install
>> Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
# ruby -v
>> ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]
[maybe so] I get an error when try push:
# heroku run rake db:migrate
>> Running rake db:migrate attached to terminal... up, run.5384
>> /usr/bin/env: ruby1.9.1: No such file or directory
and local:
# rake db:migrate
>> rake aborted!
>> cannot load such file -- bundler/setup
Thank you...
In your Gemfile add
ruby '2.0.0'

rake assets:precompile error message: No such file or directory -- ruby

I'm following along to the excellent Michael Hartl Rails book (Rails 3.2) but am getting an error when attempting to run the command:
rake assets:precompile
The error is as follows:
/Users/Jamie/.rvm/rubies/ruby-1.9.3-p448/bin/ruby ruby /Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/bin/rake assets:precompile assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/Users/Jamie/.rvm/rubies/ruby-1.9.3-p448/bin/ruby: No such file or directory -- ruby /Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/bin/rake assets:precompile (LoadError)
rake aborted!
Command failed with status (1): [/Users/Jamie/.rvm/rubies/ruby-1.9.3-p448/b...]
/Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/gems/actionpack- 3.2.14/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/gems/actionpack-3.2.14/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/bin/ruby_executable_hooks:14:in `eval'
/Users/Jamie/.rvm/gems/ruby-1.9.3-p448#movies/bin/ruby_executable_hooks:14:in `<main>'
Tasks: TOP => assets:precompile
Thanks for your help!
I fixed this by reverting back from p448 to p392 and then running:
rvm ruby-1.9.3-p392#global do gem install executable-hooks
as suggested by mpapis here: Rake assets:precompile cannot find ruby
I was trying to run the rake command within ubuntu and was getting ruby_executable_hooks error. I resolved it with:
rvm all do gem install executable-hooks
This seems to be an issue with 1.9.3-p448. Today I updated ruby from p392 to p448 on my server and started getting this error. I reverted back to p392 and precompilation of assets is working again.
Perhaps try installing a version before p448 and try again.
After working with this a bit more, I found that emptying and reinstalling my gems caused precompilation to start working again:
$ rvm gemset empty
$ bundle install
$ rake assets:precompile RAILS_ENV=production

"Missing these required gems" on specific server, gems are installed

Trying to run rake db:migrate I get:
$ rake db:migrate
(in /home/user/domains/staging)
log level debug
Missing these required gems:
haml ~> 3.1.4
htmlentities
fastercsv
You're running:
ruby 1.8.7.72 at /usr/bin/ruby1.8
rubygems 1.3.7 at /home/user/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
rake aborted!
no such file to load -- json
I have two servers en both are updated via a git repository. On one server everything works fine, on the other I get the above error.
Whats up?
Have you tried bundle install or sudo bundle install in production? You might also try bundle exec rake db:migrate instead of just rake db:migrate. These are kind of guesses, but might help.
Is the path to the "ruby"/"rake" etc executables pointing at the correct one on the server that isn't working? It looks like you want to use REE, but your stack trace is 1.8, not REE.
You may need to export an environment variable to update your path to point at the correct Ruby binaries.

Problems with Rake and Ruby on Rails

I have been trying to run rake but it seems that ever since I updated ruby gems rake is failing.
This morning I ran:
gem update --system
And ever since, rake has been failing with the following error:
$ rake db:migrate
rake aborted!
undefined method `specifications' for "/usr/lib/ruby/gems/1.9.1":String
/home/cknadler/projects/ecommerce/Rakefile:7:in `<top (required)>'
(See full trace by running task with --trace)
I have been reading about this problem and it seems that there is a problem with rake 0.9.x that breaks rails but when I check my rake version, I am running 0.8.7:
$ rake --version
rake, version 0.8.7
I have tried uninstalling rake and reinstalling it, using bundler, etc and at this point I am pretty stuck. Thanks in advance.
Edit:
My Rakefile (located in my app root directory)
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
Ecommerce::Application.load_tasks
I would suggest using the bundled binary version of rake to avoid this issue.
bundle exec rake db:migrate
If you installed your bundle using binstubs (bundle install --binstubs) then you can also use the bin version of rake which is equivalent to the bundle exec rake command:
bin/rake db:migrate
P.S: I would also recommend using RVM instead of installing Ruby using sudo for all users. This allows you to keep more modular ruby and gem installation.
You should remove rake 0.9.x (you may have 0.9.2 installed) by doing
gem uninstall rake -v=0.9.2
And then run bundle update
bundle update
Hope that helps.

Resources