piotrmurach / tty

Toolkit for developing sleek command line apps.
https://ttytoolkit.org
MIT License
2.5k stars 78 forks source link

`teletype new` errors if path contains space #57

Closed reentim closed 4 years ago

reentim commented 4 years ago

Describe the problem

It seems teletype isn't escaping / quoting the relative path (i.e. app name) for bundler, which then errors due to invalid arguments.

Steps to reproduce the problem

cd ~/
mkdir 'weird dir' && cd 'weird dir'
teletype new app

Actual behaviour

teletype new app returns 1, prints traceback:

ERROR: "bundle gem" was called with arguments ["/Users/tim/weird", "dir/app"]
Usage: "bundle gem NAME [OPTIONS]"
Traceback (most recent call last):
        9: from /Users/tim/.rbenv/versions/2.6.5/bin/teletype:23:in `<main>'
        8: from /Users/tim/.rbenv/versions/2.6.5/bin/teletype:23:in `load'
        7: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-0.10.0/exe/teletype:14:in `<top (required)>'
        6: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        5: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        4: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        3: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        2: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
        1: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-0.10.0/lib/tty/commands/new.rb:126:in `execute'
/Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-command-0.9.0/lib/tty/command.rb:106:in `run': Running `bundle gem /Users/tim/weird dir/app --no-mit --no-exe --coc --no-ext -t rspec` failed with (TTY::Command::ExitError)
  exit status: 15
  stdout: ERROR: "bundle gem" was called with arguments ["/Users/tim/weird", "dir/app"]
Usage: "bundle gem NAME [OPTIONS]"
  stderr: Nothing written

Expected behaviour

For the presence or absence of spaces in the project path to make no noticeable difference to an end-user's experience invoking teletype new.

Describe your environment

I only noticed this because I store some stuff in iCloud Drive, which has this unfortunate location on disk: /Users/tim/Library/Mobile Documents/com~apple~CloudDocs.

piotrmurach commented 4 years ago

Hi Timothy,

Thanks for using tty and reporting this.

Would you have time to investigate or even better submit PR fixing the issue?

On another note, this toolkit needs to undergo a few significant changes. Hopefully next year I will get some concentrated chunks of time to get things improved.