1

I am trying to use twurl and I've been running into an issue. I have installed ruby, and I have installed Twurl. I know this because I can run gem list and I see twurl 0.9.6 as one of the listings. However, when I attempt to run twurl authorize I get this response: -bash: twurl: command not found.

I currently have gems installed in this path: /usr/local/opt/ruby/bin/gem, which may be the issue? But I am going to that directory when I try to run the code so shouldn't it still work? I'm not the most experienced coder, so my apologies if this is obvious. Thanks!

cbagin
  • 13
  • 3
  • To run the command from the current directory, you have to type `./twurl`. But it's more convenient to just add the path(s) of your binaries to your `PATH` environment variable. – Stefan Dec 07 '20 at 16:14
  • I have now tried going to /usr/local/opt/ruby/bin/gem/twurl, and also to /usr/local/opt/ruby/bin/gem and its telling me neither of those are directories. Maybe I'm misunderstanding what you are saying? – cbagin Dec 07 '20 at 19:06
  • I assumed that you are in the binary's directory. However, figure out where your gem's binaries are installed and add that directory to your `PATH`. That way you can execute them like any other command. – Stefan Dec 07 '20 at 19:21
  • My apologies for my ignorance, really not trying to waste your time. So I ran gem env and found 3 gem paths and the executable directory, but when I navigated to each of those directories and then tried to run twurl it still wouldn't work in any of them. You keep saying add the directory to my PATH - does that mean just do cd /././././ until I get to the directory? Not sure I follow. – cbagin Dec 07 '20 at 20:25

1 Answers1

4

There isn't enough information in your post to say what happened. Rather than try to get the information from you, it's probably easier to tell you what can go wrong and let you figure it out yourself.

When installing gems, gems may include an executable file and gems may install the executable in a specific directory on your filesystem. Sometimes this works and sometimes it doesn't. For example, maybe the executable gets copied to a directory that isn't in your PATH so you can't run it from anywhere like you expect to be able to do. That's probably the case here.

I recommend that you find where twurl is installed and then add that path to your PATH and retry your operation.

  1. Run gem info twurl to get the Installed at path. Save that path for the next step.
  2. Run find PATH_FROM_PREVIOUS_STEP -name "twurl" 2>/dev/null to find the location of twurl, e.g., if the previous step said the gem was installed at /usr/bin/local/gems then you would run find /usr/bin/local/gems -name "twurl" 2>/dev/null; the output is the path to the executable, e.g., /usr/bin/local/gems/twurl/0.9.6/bin/twurl

If step 2 doesn't return the path the executable then you can retry with find / -name "twurl" 2>/dev/null to search the entire filesystem to find it.

Now that you have the path, you can run twurl one of two ways. Either use the full path every time:

$ /usr/bin/local/gems/twurl/0.9.6/bin/twurl

Or add it to your path:

$ export PATH=$PATH:/usr/bin/local/gems/twurl/0.9.6/bin/twurl

The latter option will work only for the lifecycle of your shell session. You would need to add it to your shell profile (depends on which shell you use, so no definitive answer available) so that it applies to future sessions.

anothermh
  • 9,815
  • 3
  • 33
  • 52
  • First off, thank you for your help. I have found the path, and now I am able to open twurl. It appears in a new terminal window. But I am unable to type anything in that new window. And in the original terminal it still says that the twurl command can not be found. – cbagin Dec 07 '20 at 21:25
  • Then you have a different problem, separate from the problem you originally posted about. You should [upvote this answer, mark it as accepted](https://stackoverflow.com/help/someone-answers), then post a new question that starts fresh with the problem that you're experiencing, as it is outside the scope of this question. – anothermh Dec 07 '20 at 21:39
  • Awesome, thanks for your assistance @anothermh – cbagin Dec 07 '20 at 22:05