How do you install pry plugins? - ruby

I've read about these great pry plugins (e.g. pry-debugger, pry-stack_explorer), but after nearly 30 minutes of searching, I can't find any documentation on how to install them. I've gone to their github site, the pry wiki and read/watched several tutorials, but there's nothing in there about installation.

Every pry plugin that start with pry- are auto-loaded. You just need to gem install pry-name.
Here is the link about plugins(creating plugins too) and exact quote:
A valid Pry plugin is a gem that has the pry- prefix (such as the
pry-doc gem)
If a Pry plugin is installed (i.e a gem with the pry- prefix is
installed) it will be loaded automatically when a session starts.
Note: pry has special command gem-install gem_name. You should use that command instead of .gem install gem_name in order to work. This (pry)command install and(!) reload gem cache.
If that won't work try installing gems from console then running pry.
ps. you can check installed plugins via pry --installed-plugins(in console) or in pry just type help and it will show you available commands.

Related

Can't install gem using Bundler's Rakefile install task when developing a custom gem

I'm developing a couple of private gems and I think I don't understand correctly the PATH/GEM_PATH and/or Bundler/RVM installation flow, would love if someone could chip in.
I have a repository with two gems (A & B for simplicity sake). I've developed the gems using the scaffolding + following the guidelines provided by this bundler tutorial.
Thanks to the Bundler project I have a few Rakefile tasks like rake build, rake install, rake install:local and rake release. Because of the private nature of these gems I can't release them to RubyGems (and we haven't looked into hosting our rubygems).
My machines are using RVM to manage ruby versions and Bundler version 1.15.1
What I want to do: Assuming a new machine/developer trying out the project, ideally we would cd into each of the subfolders (currently 2, gem A and gem B), run rake install and after that we should have the gems available system wide for the current user.
What is happening: The gems are built and work properly, but they are only available inside the subfolder of each gem i.e. gem A is only available inside the subfolder A and gem B is only available inside subfolder B.
What I've tried: So, after rake build/install/install:local a new .gem file is generated under pkg. I've tried to manually install the "compiled" file using gem install pkg/A.gem, gem install --local pkg/A.gem and gem install --local --user-install pkg/A.gem without success. (there are plenty of SO questions/answers about this)
I believe this has something to do with the PATH variables, but like I said before I don't fully understand the way they are managed. I get the following results from these commands:
# Our gem
> gem which A
/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/A-0.1.8/lib/A.rb
# Pry, available globally
> gem which pry
/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/pry-0.11.1/lib/pry.rb
I've been lost and frustrated for far too long now, any help is appreciated. Also open to hear suggestions of better private gem installation flows :)
Yes, it has something to do with your PATH variables. Your installation seems to be good.
I advise you to first affirm your gems installation path with:
echo $GEM_HOME
The double check your PATH to ensure its present and also confirm that the GEM home is also where the gem got installed into from the rake install
echo $PATH
If not, put it in your path and you should be fine with something like this:
echo PATH=$PATH:$GEM_HOME >> ~/.bashrc
source ~/.bashrc
Build your gem as per that guide you linked. You should end up with a gem file. Distribute this as you see fit (I use rsync/crontab to download newer gem versions but anything goes). User can install the gem as follows:
gem install --user-install /path/to/your/file.gem
This will install the gem in the user's ~/.gem/ruby/<version>/gems/<your-gem-name> directory.
Tried it with an empty gem (foodie, as in that example guide) and it works fine. But if you don't specify the --user-install parameter it will try to install in the system ruby dir (/usr/lib/ruby/gems...)

Rubymine debugging

I have Installed
2017.1.5 Version of Ruby
ruby-2.4.1-p111
I've made a new project and named it hello.rb. When I run it, everything works fine. However when I try to debug the project I get a prompt message
The gem debase required by the debugger is not currently installed. Would you like to install?
Error running hello. Following gems were not installed:
I've tried re-installing everything and restarting and I don't know what is the problem.
Well apparently debugger in RubyMine does require this gem. So You have multiple ways of doing this.
Assuming your File > Settings > Languages & Frameworks > Ruby SDK and Gems
contains only one ruby version and its the selected one (and the gem really isn't in the list). As halfelf said in your terminal/cmd/iterm you would simply write
gem install debase
Also you could create file called Gemfile that would have all the gems in
source 'http://rubygems.org'
gem 'debase'
and in the future any other gems you would need, Rubymine should be able to install those for you.
If you would have already installed the gem, there might be a gem installation conflict that would need to be resolved.

Is pry available in nitrous.io?

I would like to use pry while debugging Ruby code in nitrous.io. I updated RubyGems, but still cannot use it. Is it available in nitrous.io? How can I add it to my gems?
Have you tried to install it in the console by writing
gem install pry
or if you're trying to do rails
gem install pry-rails
because for me it worked perfectly, I had to close the console once and open a new one before it worked. I hope this helps

how do I install a ruby plugin in Powershell?

I'd like to install the scheduler_daemon plugin. I get to this part of the instructions and I'm stuck.
script/plugin install git://github.com/ssoroka/scheduler_daemon.git
# Install required gems
gem install daemons rufus-scheduler eventmachine chronic -s http://gemcutter.org
Error:
The term 'script/plugin' is not recognized as the name of a cmdlet, function...
Ok, so I preface it with Ruby:
PS>ruby script/plugin install git://github.com/ssoroka/scheduler_daemon.git
D:\Ruby193\bin\ruby.exe: No such file or directory -- script/plugin (LoadError)
I then tried ruby script/plugin install calendar_helper but got the same error. I tried putting script/plugin in quotes. I tried putting a trailing slash. I tried using http://github.... There are other things I've tried, to no avail.
What do I need to do to install a Ruby plugin via Powershell?
Found it shortly after: rails plugin install git://github.com/ssoroka/scheduler_daemon.git
The thing I've learned about Rails: any info that isn't on an official Rails site may be very outdated. Go to http://guides.rubyonrails.org/ first, second, then stackoverflow, then the rest of the net.
Before Rails 3
ruby script/plugin install git://github.com/ssoroka/scheduler_daemon.git
should work, provided you are at the root of your Rails app.
From Rails 3 onwards, this has become rails plugin install

Installing a gem from Github with Bundler

I am trying to use the instructions here to install a pre-released version of a gem with bundler.
The "bundle install" output lists the gem as getting installed, but "gem list" fails to find it.
My Gemfile:
source :gemcutter
gem 'sinatra', '1.1.0', :git => 'http://github.com/sinatra/sinatra.git'
gem 'RedCloth', '4.2.3'
Here is a gist with the rest of my sample code.
Has anyone gotten this scenario to work?
NOTE: I am also using RVM (on OS X). bundle show does list the gem (and dependencies) as existing, but I am not able to properly resolve them.
Thanks.
I would look at the load paths, and further debug from there, example:
...(master) $ irb
irb(main):001:0> $LOAD_PATH.count
=> 8
irb(main):004:0> require 'bundler/setup'
=> true
irb(main):005:0> $LOAD_PATH.count
=> 112
irb(main):006:0>
Bundler configures the load path for you, this means not all the gems are included on your load path by default.
Additionally, from the bundler git help:
Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup.
Best regards, hope this helps
ED
Bundler might have installed it locally to your app. This could vary wildly, depending on OS and whether you are using RVM.
What is the output of bundle show sinatra?
In my case, sinatra was installed here:
/home/marshall/.rvm/gems/ruby-1.8.7-p302#3846859/bundler/gems/sinatra-9cfa74a7f352
Sinatra doesn't show in the gems list, but the server launches correctly if I execute rackup.
Gems installed via bundler on Engine Yard go to a different folder to isolate them.
it's usually /data/APP_NAME/shared/bundled_gems
To be sure, check your .bundle/config file on your APP folder at Engine Yard
It looks like there is an issue using Shotgun and Bundler (git repositories only).
If I use rackup to start up my app, all is well. I am going to investigate a little more and then file a bug with one (or both) of the projects.

Resources