1

How come I can echo the $RUBYPATH variable:

[grant@rails-box app]$ echo $RUBYPATH
/opt/rubies/ruby-2.3.0

And ls that directory:

[grant@rails-box app]$ ls /opt/rubies/ruby-2.3.0
bin  include  lib  share

But I can't ls using the variable?

[grant@rails-box app]$ ls $RUBYPATH
: No such file or directoryes/ruby-2.3.0
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
gh4x
  • 818
  • 1
  • 10
  • 16
  • 5
    Given that the error message appears garbled, the variable may have embedded unprintable characters: `echo $RUBYPATH | cat -vet` – bishop Aug 23 '16 at 16:58
  • 2
    Specifically, the value of `RUBYPATH` ends with a carriage return. You need to fix this where `RUBYPATH` is set. Likely, you are reading from a file that uses DOS line endings. – chepner Aug 23 '16 at 17:22
  • 1
    And extending the advice, run `dos2unix` on your ~/.bashrc (or whatever file declares that variable). – glenn jackman Aug 23 '16 at 17:42
  • Absolutely right. I had ^M line endings in there... Thanks windows. – gh4x Aug 24 '16 at 14:44

1 Answers1

3

Bishop is right: try

$ echo $RUBYPATH | cat -v # or hexdump -C 
Community
  • 1
  • 1
James K. Lowden
  • 7,574
  • 1
  • 16
  • 31