Skip to content

Railsties yarn.rake fails when the Rails.root folder name has spaces in its name. #40783

@thebravoman

Description

@thebravoman

Steps to reproduce

Create a rails folder that has spaces in its name.
Example is "is-commands Build and Release/workspace"
The folder in question is "/var/lib/jenkins/jobs/is-commands Build and Release/workspace" and the rails project is located in it.

Build a rake task that calls:

Rake::Task["assets:precompile"].invoke

Expected behavior

Yarn completes successfully. Precompilation completes successfully.

Actual behavior

Errno::ENOENT: No such file or directory - /var/lib/jenkins/jobs/is-commands
/usr/local/rvm/gems/ruby-2.6.5/gems/railties-6.1.0/lib/rails/tasks/yarn.rake:13:in ``'
/usr/local/rvm/gems/ruby-2.6.5/gems/railties-6.1.0/lib/rails/tasks/yarn.rake:13:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.6.5/gems/is-gcc_tools-1.3.18/lib/tasks/is/gcc_tools_tasks.rake:172:in `assets_and_closure' (this calls Rake::Task["assets:precompile"].invoke)
/usr/local/rvm/gems/ruby-2.6.5/gems/is-gcc_tools-1.3.18/lib/tasks/is/gcc_tools_tasks.rake:139:in `block (3 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/usr/local/rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'

System configuration

Rails version: 6.1

Ruby version: 2.6.5

Update 1

Yesterday this was working with

Using railties 6.0.3.4

Today it is not working with

Using railties 6.1.0 (was 6.0.3.4)

About 150 projects have failed because of this. Trying to understand it further.

Update 2

The problem is in

[9, 18] in /usr/local/rvm/gems/ruby-2.6.5/gems/railties-6.1.0/lib/rails/tasks/yarn.rake
    9:       valid_node_envs.include?(Rails.env) ? Rails.env : "production"
   10:     end
   11: 
   12:     byebug
   13:     yarn_flags =
=> 14:       if `#{Rails.root}/bin/yarn --version`.start_with?("1")
   15:         "--no-progress --frozen-lockfile"
   16:       else
   17:         "--immutable"
   18:       end
(byebug) Rails.root
#<Pathname:/var/lib/jenkins/jobs/is-commands Build and Release/workspace/test/dummy>
(byebug) `#{Rails.root}/bin/yarn --version`
*** Errno::ENOENT Exception: No such file or directory - /var/lib/jenkins/jobs/is-commands

nil

You can not call #{Rails.root}/bin/yarn --version when there is a space in the name of the folder

This was introduce about 2 days ago with bd4d8fd
I am not sure If I should tag the people that have made the commit (please tell me if I should not)
@rafaelfranca @doits

I do have yarn in

jenkins@vpszap6s:~/jobs/is-commands Build and Release/workspace/test/dummy/bin$ ls
bundle  rails  rake  setup  update  yarn

I could prepare a PR if you want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions