Questions tagged [irb]

Interactive Ruby (IRB) is a shell for programming in Ruby. The program can be launched from a command prompt and allows the execution of Ruby commands line by line.

Filter by
Sorted by
Tagged with
0 votes
2 answers
41 views

Why Visual studio don't give me an output?

i'm newbie in Ruby. Today i was coding some home exercise and founding this behavior of my code: if i try to execute the same code in irb and VSC in second case i don't get a single string of output. ...
Konbar's user avatar
  • 1
0 votes
1 answer
25 views

Prevent Rails console from removing consecutive linebreaks

I'd like to prevent the Rails console from removing consecutive linebreaks: CoolApp (PRODUCTION) > a = ' CoolApp (PRODUCTION) " hi CoolApp (PRODUCTION) " CoolApp (PRODUCTION) " ...
duhaime's user avatar
  • 26k
0 votes
1 answer
41 views

IRB Keyboard Shortcuts are disabled? Can these be re-enabled? What did I break?

Expected behavior: Keyboard shortcuts using readline shortcuts like this answer. What actually happens: Ctrl+l is pressed to clear the screen irb 2023-08-08 20:31:17 -0600 Loaded Profile methods irb....
deftclaw's user avatar
1 vote
2 answers
64 views

How can remove multiline output with Rails console (Rails 6.1.7.2/Ruby 3.1.2)?

After upgrading to Rails 6.1.7.2 and Ruby 3.1.2, the way ActiveRecords are displayed in the output of the rails console is really annoying me. Basically, each record's attributes and values are ...
JoshingYou's user avatar
0 votes
0 answers
75 views

Ruby multistage build are failing

While deploying/testing the Ruby application locally I'm getting this error: root@bbd7925ec418:/# docker-compose up --build Error response from daemon: failed to create shim task: OCI runtime create ...
Shaak's user avatar
  • 3
5 votes
2 answers
294 views

Rails 7 IRB console inserts escape key instead of execute delete command

I am using Mac OS and since latest rails version the delete key does not work anymore. ❯ rails -v Rails 7.0.4 ❯ ruby -v ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21] When I hit ...
YvesR's user avatar
  • 6,002
0 votes
1 answer
39 views

What is the traceback/local jumpback error in irb repl when writing multiline code?

I am a newbie, forgive if this is an obvious question but does anyone know why my irb repl isn't able to do multilines? I have tried lots of different if statements (copied from course notes that I am ...
NIcolaHearn's user avatar
0 votes
1 answer
305 views

Rails console overriding `~/.irbrc`

I have the following in my ~/.irbrc file: require 'irb' require 'rubygems' require 'awesome_print' AwesomePrint.irb! IRB.conf[:USE_AUTOCOMPLETE] = false IRB.conf[:ECHO_ON_ASSIGNMENT] = true IRB.conf[...
johnpitchko's user avatar
-3 votes
1 answer
518 views

Ruby on Rails undefined local variable or method in console [closed]

What is problem? I don't understand.
Azizbek Nusratilloyev's user avatar
2 votes
0 answers
99 views

adding search function to my rails API (with pg_search), model comming from external DB, getting Object doesnt support #inspect

i know there are several questions like this one, but this is a bit different since my model is not stored in rails database, it is coming from an external db. I implemented pg_search in the model, ...
Seb's user avatar
  • 21
6 votes
4 answers
488 views

Ruby 3 IRB home end and ctrl-u not working

I've recently started using Ruby 3 more and it seems the home key (to take me to the beginning of the line) the end key (end of the line) and ctrl-u (clear the line) aren't working. I'm running Arch ...
KNejad's user avatar
  • 2,426
0 votes
1 answer
266 views

No history for rails console

irb works fine, rails console doesnt! ~/.irbrc require 'irb/ext/save-history' IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" > irb irb(main):...
Ian Vaughan's user avatar
  • 20.4k
-1 votes
1 answer
128 views

How to copy object from one shell to another shell?

You have two open IRB shells in separate terminal windows. The first shell has the following code already entered: class Apple attr_reader :variety, :origin, :history def initialize(**args) @...
Ayush's user avatar
  • 1
0 votes
1 answer
110 views

Copy paste from irb excluding prompt at start of line?

When copy/pasting from irb to an .rb file the start of each line should be removed. A short example, say you copy this from irb: irb(main):049:1* def thing(x, y) irb(main):050:1* out = x * y irb(...
stevec's user avatar
  • 43.4k
0 votes
0 answers
127 views

Ruby gem - How do I test my own ruby gem via IRB?

Okay so I am completely new to using IRB so I have no idea what I am doing wrong. Here is my gem that I built # frozen_string_literal: true require_relative "badwordgem/version" require '...
mrOlympia's user avatar
  • 321
1 vote
0 answers
144 views

Rails console (in docker-compose) hangs when I try to paste a string with an extended character such as "Vötest"

On my Mac: Copy the string n = "Vötest" to my clipboard from my code editor (Sublimetext 3.2.2) Launch Rails console rails c irb(main):001:0> Attempt to paste the string to ...
jpw's user avatar
  • 18.8k
2 votes
1 answer
53 views

How to make irb output the same on Ubuntu and Windows?

I'm have irb 1.4.1 (2021-12-25) on Windows 10 and Ubuntu 16.04. On Windows, When I type in irb 1+2, on Windows I get # => 3, but on Ubuntu I get => 3. For me this is not a trivial matter, ...
Burdette Lamar's user avatar
1 vote
2 answers
159 views

Ruby 3.1.0 encoding(?) problem in irb (RubyInstaller Windows 10)

Since the update to 3.1.0 via RubyInstaller under Win 10 there is a problem with alt gr in irb. When I try to enter { (German keyboard alt gr + {) I get ^[{. Any idea what's going wrong? BTW 3.0.2 was ...
Eric's user avatar
  • 163
0 votes
0 answers
52 views

Remove ruby 3.1 autocomplete feature for heroku console [duplicate]

The autocomplete feature from Ruby 3.1 is really nice on local environment but makes the one-off Heroku dyno really slow. How could I remove the autocompletion with an .irbrc file? I tried something ...
yoLotus's user avatar
  • 193
8 votes
3 answers
2k views

Disabling irb autocomplete on Heroku

A follow up to Disable irb autocomplete I would like to disable IRB on Heroku, e.g. having an .irbrc with: IRB.conf[:USE_AUTOCOMPLETE] = false In the home directory of my heroku dyno/server How can I ...
Dorian's user avatar
  • 8,027
74 votes
3 answers
11k views

Disable irb autocomplete

The latest version of irb introduced an autocomplete that is quite buggy and I don't generally like to be distracted by an autocomplete, any idea how I can disable it? Related question: How to ...
Dorian's user avatar
  • 8,027
1 vote
2 answers
590 views

Ruby console - Multiline command with exit

I have a simple ruby script I would like to run in the rails console, using bundle exec rails c ids = [1, 2] if ids.length() > 5 puts "More than 5 ids, quitting" exit end ids....
user3371750's user avatar
1 vote
1 answer
375 views

Possible to configure rails to load per project .irbrc file?

Can rails load .irbrc from the rails project root such as ~/rails-projct/.irbrc. Rather then ~/.irbrc. Since it would be nice to add configuration that's specific to a project.
Baxter's user avatar
  • 142
1 vote
1 answer
195 views

How can I paste multiple line command with Docker interactive mode but not evaluating?

For example I am opening an interactive command line window. docker exec -it container rails c When I paste a multiple-line command, it evaluate every line instead of pasting a block. How can I ...
Rockman12352's user avatar
2 votes
1 answer
481 views

how can options be passed to rails console in heroku

While trying to pass options to rails console in Heroku the following error is shown: > heroku run rails console -- --nomultiline Running rails console "-- --nomultiline" on ⬢ the-app... ...
estani's user avatar
  • 24.7k
0 votes
2 answers
70 views

How do I access functions of an instance variable of a class, within another class?

Take this for example: class Inner attr_accessor :id, :number def initialize(id, number) @id = id @number = number end def id() ...
Talk about nostalgia's user avatar
0 votes
0 answers
201 views

Rails console doesn't work after update RoR

After update rails to 6.1.4 version and ruby to 3.0.0 and update my Ruby on Rails APP I cant start the rails console either IRB and it doesn't show any error. Tests performed I have installed the IRB ...
Harold Alcalde Solarte's user avatar
0 votes
2 answers
432 views

Ruby irb utf-8 encoding problem on windows 10 terminal input

I want to use ruby with terminal input in my windows. Why ruby community can not solve this UTF-8 issue on windows? Is it hard? I am wondering how python, java or other langs did this? I can work ...
Sercan Tırnavalı's user avatar
1 vote
1 answer
687 views

Why 'irb' shell exits instantaneously in docker command

This is my Dockerfile. FROM ruby:2.4.0-alpine RUN mkdir /app WORKDIR /app COPY Gemfile ./Gemfile COPY Gemfile.lock ./Gemfile.lock RUN bundle install -j 20 COPY . . This is my docker-compose file: ...
Asad Iqbal's user avatar
  • 3,271
2 votes
1 answer
2k views

Ruby NoMethodError (undefined method ''...' for '....:Class'

require_relative 'json_lookup' require_relative 'csv_lookup' require_relative 'error' BASE_RATE = 'EUR' class CurrencyExchange def initialize(file:, date:, from:, to:) @file = file @date =...
user avatar
12 votes
4 answers
3k views

how can I change the default syntax coloring in ruby 3.0's IRB

I'm very happy to be using the most recent ruby 3.0; as well as having access to the updated command-line interpreter which does syntax highlighting and coloring. However, the colors are a bit hard to ...
Simon DeDeo's user avatar
2 votes
0 answers
28 views

How can I consistently prefix IRB return values with a custom comment string in Ruby >= 3.0.0?

I have the following in my ~/.irbrc file: IRB.conf[:PROMPT][:DEFAULT][:RETURN].prepend ?# In earlier Ruby versions, this would ensure that each return value was prefixed with a comment symbol rather ...
Todd A. Jacobs's user avatar
1 vote
0 answers
214 views

Why doesn't IRB display output when executing in VS Code Terminal?

Newbie here.. I'm trying out VS Code and am running into an issue. I've connected VS Code to WSL through remote connection and everything is running great expect for IRB.. When I open IRB in the ...
Byron Pearce's user avatar
0 votes
3 answers
327 views

Automatically load Dotenv on my ruby console

I'd like to automatically run Dotenv.load('.env.development') whenever I launch up a ruby console, it could either be from bundle console or alternatively irb. I'm using Sinatra, not Rails, and I'm ...
Ben G's user avatar
  • 26.2k
0 votes
1 answer
165 views

Ruby: how to access group info from /var/db/group.db

RHEL/CentOS 8.x, Ruby 2.5.5, irb 0.9.6 We have a specialized set up that keeps user and group information in /usr/local/etc/[user|group] and a custom Makefile to add that information to /var/db/[group|...
datakid's user avatar
  • 2,383
1 vote
1 answer
84 views

In irb while defining a method named 'method', wrong number of argument apperaed

after define a method named 'method' in irb/gry def method puts 1 end Traceback (most recent call last): 33: from F:/Ruby27-x64/bin/irb.cmd:31:in `<main>' 32: from F:/...
zhenwei liu's user avatar
6 votes
2 answers
801 views

How can I add a new line in Ruby 2.7+ IRB multiline edit mode?

Ruby 2.7 introduced an update to IRB that allows multiline editing. How can I add a new line into a multiline method to inject code between two previous statements? E.g. 2.7.1 :019 > while session =...
Aaron's user avatar
  • 13.5k
0 votes
1 answer
77 views

Using .reverse in irb

In IRB, .sort is working well. (1..10).to_a.sample(5).sort => [1, 3, 6, 8, 9] However, .reverse is not working (1..10).to_a.sample(5).reverse => [4, 3, 10, 2, 1] How can I get result of that is ...
Rinic's user avatar
  • 41
0 votes
1 answer
196 views

Ruby on Rails testing connection to DB through irb , NameError Uninitialized Constant Article

I’m running into an issue where I want to test out the connection to the db. I’m trying to access my Articles table. I have a file in models “article.rb” and inside it has: class Article < ...
SK Sam's user avatar
  • 37
-1 votes
1 answer
426 views

For loop not working with string.length in Ruby irb

In irb, bash shell, on a mac. As you can see, a is a defined array. Putting a.length in parens makes no difference. The output should be the array, but no output appears. >> a => ["ant&...
Omne Bonum's user avatar
1 vote
0 answers
34 views

Ruby object's console view beautifier - is there something like that?

In Ruby console we can show an object in a form like that: #<ActiveSupport::Cache::MemcachedStore:0x00005649aedceb20 @swallow_exceptions=true, @options={:namespace =>"dfw_cache", :...
Karol Selak's user avatar
  • 4,360
0 votes
1 answer
56 views

What's the difference between TOPLEVEL_BINDING and binding?

I opened irb and checked the value of binding and TOPLEVEL_binding: 2.7.0 :021 > TOPLEVEL_BINDING => #<Binding:0x00007fbd7d85bb18> 2.7.0 :022 > binding => #<Binding:...
Cam's user avatar
  • 15k
-1 votes
1 answer
226 views

Can I instantiate a class from a method within another class? (Ruby)

I've redone the question and included the full code for both files. In the touch_in method I am trying to instantiate a Journey class in the variable called 'journey'. require_relative 'journey' ...
PaulM's user avatar
  • 1
3 votes
2 answers
1k views

Why is the RubyMine console failing to start?

I'm running the latest RubyMine, 2020.1.1 (Build #RM-201.7223.94), Ruby 2.7 and Rails 6.0.2.2. When I try to start a Rails console, I get this error: C:\Users\pupeno\scoop\apps\ruby\current\bin\ruby....
Pablo Fernandez's user avatar
0 votes
0 answers
660 views

Visual Studio code. Terminal. Arrows don't work in Irb and Rails Console

I can observe really weird behavior of the integrated terminal in VSCode. When I work with irb or rails console (for my Ruby on Rails project), the arrow keys don't work. So I can't use my command ...
Ivan's user avatar
  • 115
1 vote
1 answer
100 views

Simulating selecting a file for Active Storage in irb

Creating a new item for Active Storage. <!-- app/views/docs/_form.html.erb --> <%= f.label :image, "Select document or image that support this information." %> <%= f.file_field :...
Greg's user avatar
  • 2,439
1 vote
1 answer
626 views

Is it possible to place the .irbrc file in the project folder?

I would like to place the .irbrc file in my project folder to configure the irb console just for that specific project. I am aware that i can configure .irbrc placing it in the home folder but i would ...
Rafa H's user avatar
  • 13
0 votes
1 answer
446 views

Memory leak in ruby

I have such code in irb: 2.6.3 :001 > a = []; 100000000000.times do a.push([1]) end ^CTraceback (most recent call last): 3: from (irb):1 2: from (irb):1:in `times' 1: from (...
mpz's user avatar
  • 1,722
0 votes
0 answers
145 views

Rails Console is not querying the table in Rails 6

Altruists, I am new in Rails, I have a devise user model named Account. I have signed up with my email, and I want to query my Account table from rails console, like I did in Rails 5 without any ...
Shimol Khan's user avatar
0 votes
1 answer
154 views

Debug Ohai plugins in irb shell

I've installed a chef-workstation on my computer. ohai --version #returns: 15.7.4 I also installed the Ohai cookbook from the supermarket. If I integrate this into my test cookbook, the self-...
user5580578's user avatar
  • 1,194

1
2 3 4 5
16