Have Twurl installed, but I can't access it - ruby

I have installed Twurl but for some reason I still can't use it. I believe I have it installed because it shows up when I type the ls command. Then I am able to navigate to the folder that Twurl is contained in. However, I am not able to go into the Twurl folder because it says it is not a directory. I am able to use the command open twurl, which opens up a seperate terminal window with a lot of information about Twurl, but I can't type anything. One other thing, when I try and run twurl authorize I get this response: twurl: command not found So my question is, how do I go about getting twurl to work now? Such that I can run the twurl authorize command.
gem env output:
- RUBYGEMS VERSION: 3.1.4
- RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/CharlieBagin/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/CharlieBagin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/CharlieBagin/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.2/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /Users/CharlieBagin/anaconda3/bin
- /Library/Frameworks/Python.framework/Versions/3.6/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
I think I might have installed it in two places. I originally used gem install twurl, but then it wasn't working and I was trying some things and used bundler to install at some point too.

Related

Is there a way to define an alias that executes a bin from a specific folder in MacOS?

I am currently using a Macbook Pro running MacOS Mojave 10.14.3. I have recently gotten into ruby programming but find their whole gem package management a little confusing. When i gem install a package, it installs it in my /usr/local/lib/ruby/gems/2.6.0/bin folder and if I want to execute a gem or get a gem version, for example the solargraph gem, I must type a command: /usr/local/lib/ruby/gems/2.6.0/bin/solargraph -v. I was wondering if there is way for me to define an alias for the path /usr/local/lib/ruby/gems/2.6.0/bin so that I could type something like gemexec solargraph -v which would achieve the same result as /usr/local/lib/ruby/gems/2.6.0/bin/solargraph -v. Thanks for your help. BTW I am using the ZSH shell.
You can make a function that will do this for you and place it in your .zshrc file.
function gemexec() {
/usr/local/lib/ruby/gems/2.6.0/bin/"$1"
}
You can use the fact that Ruby 'install' the binary to central bin directory located at /usr/local/lib/ruby/gems/RUBY_VERSION/bin.
Use gem environment to determine your path:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.7
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/alice/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.5.0/bin
- SPEC CACHE DIRECTORY: /Users/alice/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.5.3_1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.5.0
- /Users/alice/.gem/ruby/2.5.0
- /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/gems/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Then, you can add ruby bin path into your global bin path and to get what you want -
PATH="/usr/local/lib/ruby/gems/2.5.0/bin:$PATH"
solargraph -v
0.31.3
Finally, to make zsh to use this PATH every time you open a shell, add this line into your .zsh_rc file -
echo PATH="/usr/local/lib/ruby/gems/2.5.0/bin:$PATH" >> ~/.zshrc

Permission denied, when installing a new gem

I am in Windows 7, I can see that all my gems are in :
C:\Users\alotfi2.gem\specs\api.rubygems.org%443\quick\Marshal.4.8
Last week we received an email from the admin that said :
After migration, your H: drive will be read-only. This means you'll be able to access and transfer your files but you won't be able to edit them or save any new files to your H: drive.
but when I tried to install a new gem I got :
gem install chronic
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - H:/.gem/specs/api.rubygems.org%443/quick/Marshal.4.8/chronic-0.10.2.gemspec
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.3.0
- RUBY VERSION: 2.4.2 (2017-09-14 patchlevel 198) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby24-x64/lib/ruby/gems/2.4.0
- RUBY EXECUTABLE: C:/Ruby24-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby24-x64/bin
- SPEC CACHE DIRECTORY: H:/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby24-x64/lib/ruby/gems/2.4.0
- H:/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\majid\cmder\bin
- C:\majid\cmder\vendor\git-for-windows\cmd
- C:\majid\cmder\vendor\conemu-maximus5\ConEmu\Scripts
- C:\majid\cmder\vendor\conemu-maximus5
- C:\majid\cmder\vendor\conemu-maximus5\ConEmu
- C:\Program Files (x86)\Shoes
- C:\Ruby24-x64\bin
- C:\Users\alotfi2\AppData\Local\Programs\Python\Python36-32\Scripts\
- C:\Users\alotfi2\AppData\Local\Programs\Python\Python36-32\
- C:\Users\alotfi2\AppData\Roaming\npm
- C:\Program Files\Docker Toolbox
- C:\majid\cmder\vendor\git-for-windows\usr\bin
- C:\majid\cmder\vendor\git-for-windows\usr\share\vim\vim74
- C:\majid\cmder\
your help is appreciated .
Thanks.
Your SPEC CACHE DIRECTORY still links to your H: drive, to change its value, you have to set environment variable GEM_SPEC_CACHE as stated in this thread.
To do so on Windows, you would want to use SetX command. For example:
SETX GEM_SPEC_CACHE C:\Users\User\.gem\abc
You should have writing access rights to directory C:\Users\User\.gem\abc for it to work.

Cucumber: command not found (suddenly broken)

I am trying to self-teach Cucumber and suddenly my terminal is giving me the error
-bash: cucumber: command not found
I have checked out a couple of 'similar' threads on SA and their either Rails related or aren't particularly helpful. For example this one
says about checking your gem env but doesn't give any clue as to what to check it for (at least for a UNIX/Mac noob like me). As the above post suggests typing which cucumber gives no output and my gem env looks something like this:
- RUBYGEMS VERSION: 2.4.6
- RUBY VERSION: 2.1.3 (2014-09-19 patchlevel 242) [x86_64-darwin14.0]
- INSTALLATION DIRECTORY: /Users/username/.rvm/gems/ruby-2.1.3
- RUBY EXECUTABLE: /Users/username/.rvm/rubies/ruby-2.1.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/username/.rvm/gems/ruby-2.1.3/bin
- SPEC CACHE DIRECTORY: /Users/username/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/username/.rvm/gems/ruby-2.1.3
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin/Users/username/.rvm/gems/ruby-2.1.3/bin
- /Users/username/.rvm/gems/ruby-2.1.3#global/bin
- /Users/username/.rvm/rubies/ruby-2.1.3/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/username/.rvm/bin
if anyone can shed any light on this I'd really appreciate it. Cucumber was working fine not so long ago.
doesn't work
сucumber --guess --tags #ie features...
works
bundle exec cucumber --tags #ie features...
The problem is only on IE9.
Is that problem of version ruby, cucumber?
Ruby 2.2.0 Cucumber 1.3.18

<RubyGems> How to change gem environment settings?

I installed rbenv and set up ruby and gems. Now if I run gem env then I got the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/myusername/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-13
- GEM PATHS:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /Users/myusername/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- /Users/myusername/Tools/.rbenv/libexec
- /Users/myusername/Tools/.rbenv/plugins/ruby-build/bin
- /opt/local/bin
- /opt/local/sbin
- /Users/myusername/Tools/.rbenv/shims
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
- /Users/myusername/Tools/./bin
- /Users/myusername/Tools/.rbenv/bin
Well.. all looks good except for SPEC CACHE DIRECTORY and GEM PATHS, all others have self-configured paths. (So I really don't want any dev-related directories directly placed in my user home folder.) Is there a way to flexibly change these two env variables without affecting normal functioning of ruby, gem and rbenv etc.?
Thanks!
Actually I searched online and found the solution.
Just put the following in your .profile (Max OS) or .bashrc (Linux)
export GEM_PATH=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
export GEM_SPEC_CACHE=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/specs
Make sure the folder you put there existed. Then source the .profile or .bashrc, or simply restart your terminal. It is tested working now my env is correct.
Reference:
https://github.com/rubygems/rubygems/pull/489

Ruby gems missing when run from Xcode shell script

I'm attempting to run a grunt script to compile a bunch of stuff, including grunt-contrib-compass from Xcode. Running grunt debug works fine from outside of Xcode, but not when invoked as a shell script as part of a build phase in Xcode.
running grunt debug I receive:
/Users/MY_USER/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in
`to_specs': Could not find 'compass' (>= 0) among 14 total gem(s)
(Gem::LoadError)
Having loaded in my PATH variables at the top of the script with:
PATH=$(bash -l -c 'echo $PATH')
Xcode seems to be loading in the correct versions of ruby & gem:
which ruby -> /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin/ruby
which compass -> /Users/MY_USER/.rvm/gems/ruby-2.1.0/bin/compass
which gem -> /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin/gem
These are the same as those reported from bash.
However,gem query --local returns a different list when executed within Xcode than when run from bash. This list does not contain compass - I guess this might be why I receive the Could not find 'compass' error, any idea what I can do to fix this?
Here's my gem env, as reported from the shell script executed by Xcode:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/MY_USER/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/MY_USER/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/MY_USER/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0
- /Users/MY_USER/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/MY_USER/.rvm/gems/ruby-2.1.0/bin
- /Users/MY_USER/.rvm/gems/ruby-2.1.0#global/bin
- /Users/MY_USER/.rvm/rubies/ruby-2.1.0/bin
- /opt/local/bin
- /opt/local/sbin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
- /usr/local/git/bin
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin
- /Applications/Xcode.app/Contents/Developer/usr/bin
- /Applications/Xcode.app/Contents/Developer/usr/local/bin
- /Applications/Xcode.app/Contents/Developer/Tools
- /Users/MY_USER/bin
- /Users/MY_USER/Development/adt-bundle/sdk/platform-tools
- /Users/MY_USER/Development/adt-bundle/sdk/tools
- /Users/MY_USER/.rvm/bin
So I've ended up cheating -
echo $(bash -l -c "source ~/.bashrc && cd $myProjectLocation && grunt debug")
runs the grunt command in a new bash instance, which does not inherit Xcode's environment variables, and is the same as bash outside of Xcode.
It's not perfect though - while echoing out the result of bash gives me all the log messages, they're poorly formatted, and it doesn't halt execution of the main script if there's an error.
So ideally I'd still like a proper solution to my original question, if anyone has any suggestions.

Resources