rails: No such file or directory - /usr/src/app/bin/yarn

Steps to reproduce

When I run bin/rails assets:precompile I get a Errno::ENOENT exception. Probably related to https://github.com/rails/rails/pull/40739.

Expected behavior

I expect the precompilation of assets to fallback to existing yarn when not found in bin directory.

Actual behavior

RUN RAILS_ENV=production bin/rails assets:precompile
rails aborted!
Errno::ENOENT: No such file or directory - /usr/src/app/bin/yarn
 
Tasks: TOP => assets:precompile => yarn:install

System configuration

Rails version: 6.1.0

Ruby version: 2.7.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 21 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@AnthonyFrancis looks like Rails 6.1.1 was just released and it includes the fix for yarn:install

As a temporary fix, you can add the following to your Rakefile:

Rake::Task["yarn:install"].clear

namespace :yarn do
  task :install do
    # Do nothing, since there's no yarn
  end
end

@KevinBongart fix was merged https://github.com/rails/rails/pull/40785, no need for open issue anymore.

We are still using sprockets to compile javascripts and we are getting the same error. It is was caused by this change https://github.com/rails/rails/pull/40722 (https://github.com/rails/rails/commit/b087511bc49097a6dc2afe0256bb6d39ebb3a4ab)

full stack trace:

[project#rails-6-1]→ 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
rails aborted!
Errno::ENOENT: No such file or directory - /project_path/bin/yarn
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/tasks/yarn.rake:13:in ``'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/tasks/yarn.rake:13:in `block (2 levels) in <main>'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `each'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:59:in `with_application'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/command.rb:52:in `invoke'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.1.0/lib/rails/commands.rb:18:in `<main>'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
/project_path/bin/rails:8:in `<top (required)>'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/edariedl/.rbenv/versions/2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/project_path/bin/spring:16:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => assets:precompile => yarn:install

system call swallows the problem and returns nil if command doesn’t exist. Backgticks `` on the other hand raises an exception. That is the reason it is raising exceptions.

It worked fine in 6.1.0.rc2, it was broken by final release.