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

Using Aruba in directories with spaces #490

Closed
odlp opened this issue Sep 4, 2017 · 14 comments
Closed

Using Aruba in directories with spaces #490

odlp opened this issue Sep 4, 2017 · 14 comments

Comments

@odlp
Copy link

odlp commented Sep 4, 2017

Summary

Aruba (0.14.2) isn't able to spawn processes within folders which have spaces in the name.

Expected Behavior

$ pwd
/Users/oli/workspace/aruba-spaces-bug/regrettable folder with spaces

$ bundle exec cucumber -b

Feature: Example

  Scenario: Running in a directory with spaces # features/example.feature:2
    When I successfully run `cli`              # aruba-0.14.2/lib/aruba/cucumber/command.rb:27
    Then the output should contain:            # aruba-0.14.2/lib/aruba/cucumber/command.rb:205
      """
      foo
      """

1 scenario (1 passed)
2 steps (2 passed)
0m0.113s

Current Behavior

$ pwd
/Users/oli/workspace/aruba-spaces-bug/regrettable folder with spaces

$ bundle exec cucumber -b

Feature: Example

  Scenario: Running in a directory with spaces # features/example.feature:2
    When I successfully run `cli`              # aruba-0.14.2/lib/aruba/cucumber/command.rb:27
      undefined local variable or method `cmd' for #<Aruba::Processes::SpawnProcess:0x007f95102b2328>
      Did you mean?  @cmd (NameError)
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/processes/spawn_process.rb:86:in `rescue in start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/processes/spawn_process.rb:80:in `start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/command.rb:67:in `start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/api/command.rb:213:in `run'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/api/command.rb:271:in `run_simple'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/cucumber/command.rb:29:in `block in <top (required)>'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/cucumber-2.4.0/lib/cucumber/core_ext/instance_exec.rb:25:in `instance_exec'

Possible Solution

First-off the exception is obscured due to an undefined variable / method cmd:

raise LaunchError, "It tried to start #{cmd}. " + e.message

However this has been corrected to commandline in subsequent releases of Aruba. Correcting this line locally, and re-running bundle exec cucumber -b:

Feature: Example

  Scenario: Running in a directory with spaces # features/example.feature:2
    When I successfully run `cli`              # aruba-0.14.2/lib/aruba/cucumber/command.rb:27
      It tried to start cli. No such file or directory - /Users/oli/workspace/aruba-spaces-bug/regrettable (Aruba::LaunchError)
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/processes/spawn_process.rb:86:in `rescue in start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/processes/spawn_process.rb:80:in `start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/command.rb:67:in `start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/api/command.rb:213:in `run'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/api/command.rb:271:in `run_simple'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/aruba-0.14.2/lib/aruba/cucumber/command.rb:29:in `block in <top (required)>'

The notable part here is the directory is incorrect:

No such file or directory - /Users/oli/workspace/aruba-spaces-bug/regrettable

It should be:

/Users/oli/workspace/aruba-spaces-bug/regrettable\ folder\ with\ spaces

This could be because the @process.cwd needs to be escaped with Shellwords.escape or similar:

@process.cwd = @working_directory

And possibly the command_string before being passed to ChildProcess too:

@process = ChildProcess.build(*[command_string.to_a, arguments].flatten)

Steps to Reproduce (for bugs)

git clone https://github.com/odlp/aruba-spaces-bug.git
cd aruba-spaces-bug
bundle install

# Works
cd folder-without-spaces
bundle exec cucumber

# Fails
cd ../regrettable\ folder\ with\ spaces/
bundle exec cucumber

Context & Motivation

Ideally users wouldn't be in directories with spaces, but this can happen when the same project is unzipped multiple times for example. OSX in particular creates successive filenames like: your_project, your_project (1), your_project (2).

@olleolleolle
Copy link
Contributor

Could you test the same thing, with a master aruba?

That could be done changing this line:
https://github.com/odlp/aruba-spaces-bug/blob/master/Gemfile#L4 to point to master

Link: Gems from git repositories

@odlp
Copy link
Author

odlp commented Sep 5, 2017

@olleolleolle I've just tried with master @ 6820ab3 and still get an error:

Feature: Example

  Scenario: Running in a directory with spaces # features/example.feature:2
    When I successfully run `cli`              # aruba-6820ab32e9a8/lib/aruba/cucumber/command.rb:24
      It tried to start cli. No such file or directory - /Users/oli/workspace/aruba-spaces-bug/regrettable (Aruba::LaunchError)
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/aruba-6820ab32e9a8/lib/aruba/processes/spawn_process.rb:89:in `rescue in start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/aruba-6820ab32e9a8/lib/aruba/processes/spawn_process.rb:83:in `start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/aruba-6820ab32e9a8/lib/aruba/command.rb:67:in `start'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/aruba-6820ab32e9a8/lib/aruba/api/command.rb:215:in `run_command'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/aruba-6820ab32e9a8/lib/aruba/api/command.rb:273:in `run_command_and_stop'
      /Users/oli/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/bundler/gems/aruba-6820ab32e9a8/lib/aruba/cucumber/command.rb:26:in `block in <top (required)>'

Looks like the process is being spawned in a folder which doesn't exist because the path is truncated from the first space character.

@olleolleolle
Copy link
Contributor

@odlp Thanks, now you've verified the issue still exists on master. That's super - the stacktrace is also valuable.

@maxmeyer
Copy link
Member

maxmeyer commented Sep 14, 2017

@odlp Would you love to help out and try to fix this bug yourself? I would love to see more people hacking on aruba. 😄

@mvz
Copy link
Contributor

mvz commented Nov 12, 2017

This may not be so easy: This may be a problem in the childprocess gem.

@maxmeyer
Copy link
Member

maxmeyer commented Nov 24, 2017

And this seems to be more or less unmaintained as @enkessler doesn't have the resources to work on it: https://cucumberbdd.slack.com/archives/C62GZFLLT/p1509455288000065

It's been a year or so since I took over as the sole maintainer of childprocess, but I can't really give it the attention that it deserves anymore. If anyone is interested in taking it over, please let me know.

@mvz
Copy link
Contributor

mvz commented Nov 24, 2017

I've been investigating if childprocess is still needed, since the built-in tools for Ruby have improved over the years. No conclusion yet, though.

@enkessler
Copy link

All right, I'll bite. What leads you to suspect that the problem is down a level in childprocess? Is the command being executed legit on its own? Can you system the command and get correct results?

@mvz
Copy link
Contributor

mvz commented Nov 28, 2017

@enkessler It's mainly a hunch from what I learned about its inner workings while trying to get the Aruba Windows build on appveyor to run, in particular how it quotes the command and arguments. However, I haven't looked at how childprocess works on Linux.

Can you system the command and get correct results?

Well, system works with commands that contain spaces, as long as I trick it into not starting a subshell. I'll see if I can test the exact command that fails in the tests.

@mvz
Copy link
Contributor

mvz commented Nov 28, 2017

I'll see if I can test the exact command that fails in the tests.

Well, that was very insightful. I'm preparing a fix now.

@mvz
Copy link
Contributor

mvz commented Nov 30, 2017

@enkessler it turns out this particular issue is not due to childprocess. The problem on Windows is a different one. Since I don't run Windows locally breaking this down to a concrete bug report for childprocess is a bit tricky.

@stale
Copy link

stale bot commented Jan 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Jan 29, 2018
@mvz
Copy link
Contributor

mvz commented Jan 29, 2018

Fixed in master. Needs fix on 0.14.x

@stale stale bot removed the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Jan 29, 2018
@mvz mvz added the bug label Jan 29, 2018
@mvz mvz added this to the 0.14.4 milestone Jan 29, 2018
@mvz
Copy link
Contributor

mvz commented Jan 29, 2018

Fixed in still. Will be released in 0.14.4.

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

5 participants