IntelliJ won't detect Ruby interpreter installed using asdf-vm whatsoever - ruby

Pretty weird stuff.
I have installed latest Ruby using asdf-vm. All works fine with the terminal - Ruby is being detected, I am able to install gems, and every create a Rails app and open it using VSCode.
Somehow, IntelliJ is detecting Ruby in /usr/bin/ruby. First of all, the file doesn't appear in the file system when I try to manually locate it. Also, the version of this file is different than the version I installed using asdf-vm. Next, I haven't installed Ruby using anything other than asdf-vm. Finally, I'm unable to delete the file using IntelliJ.
Now, changing the Ruby interpreter manually to /home/jaymin/.asdf/shims/ruby gives me the following error:
Error configuring SDK: Unable to read RbConfig for ruby (/home/linux-user/.asdf/shims/ruby). Please make sure that /home/linux-user/.asdf/shims/ruby is a valid home path for this SDK type.
I'm not sure what I am doing wrong.

Related

How do I set the proper Ruby version for use with my Rails 5 project in Aptana 3?

I'm usingn Aptana Studio 3 on Mac High Sierra. I have imported my Rails 5 project and set "Rails" as my project natures in the "Properties" section of my project. However when editing some Ruby files, Aptana is incorrectly reporting syntax errors on the left side of the editor. For example, this line
creds = PasswordService.find_user(params[:login])&.object
is flagged with this error
syntax error, unexpected tDOT
even though this doesn't raise any errors when I run my project. I'm wondering if Aptana is not picking up the correct version of Ruby associated with my project but I'm not sure how to check/set that.
I don't use Aptana, but maybe you want to set your Ruby version too because the safe navigation & is a Ruby feature.
In the project directory run ruby -v in the console and check the ruby version, it must be higher than 2.3.
If you use a ruby version manager (rbenv or rvm) make sure you configure the right Ruby version for the project.
Is studio3-ruby the plugin you're using?
If so, I found this open issue that seems related to Ruby 2.0 support:
https://github.com/aptana/studio3-ruby/issues/8

Eventmachine - Unable to load the Event Machine C Extension

I'm trying to run the current development version of Instiki on windows 8.1. I use ruby 2.4 . Bundle install succeeded. I also used the newest Nokogiri 1.8.0 version that was released some days ago and this fixed a compatibility issue with Ruby 2.4 on windows systems.
When I run instiki , It says that the system is unable to load the Event Machine C Extension.
In more detail the Error message is :
Unable to load Event Machine C extension: To use the pure ruby reactor use 'require'em/pure_ruby
C:\instiki\vendor\rails\activesupport\lib\active_support\dependencies.rb:184: in 'require' cannot load such a file -- rubyeventmachine (missing source file)
If I understand this correctly , A file is missing which was required in some module so I might be able to circumvent this by including some other module ( "pure_ruby" rb file) that provides the same functionality . Is this right ? I tried to re-install this gem with no effect. If this is so , how can I do this ?
Note : This is the first time I use ruby and I have limited experience in programming
Some progress : I required pure_ruby in the dependencies file , the half page error report turned to two pages of errors which I can't decipher so this might be relevant.

How to install Ruby Installer in Azure Websites

I'm using SASS in my application and i'm in the process of migrating to Azure.
I've got my project setup but it's not compiling the SASS. I'm trying to use the Ruby Installer from here http://rubyinstaller.org/downloads/ (Ruby 1.9.3-p551) and I've uploaded this via FTP to D:/home however when I try to install it simply using the command rubyinstaller-1.9.3-p551.exe it doesn't do anything. No error message or anything either.
Any suggestions?
Using the installer won't work because it probably requires an interactive session. What I did was get the Ruby binaries and FTP those to the website. You can find the binaries as as 7zip file on Ruby download page. I followed along this post: Installing Ruby 1.8.7 (and other stuff) manually. The part about zlib is probably outdated because there is a corresponding dll in the zipped archive already. I did download the other mentioned dll though (the iconv dll) and placed it in the Ruby bin folder.
Gem is already bundled in the package so no need to install that separately.
Unfortunately now I'm having difficulties in getting the gulp task to work because it is still saying "ruby and compass must be installed and in path". I set the path in the gulpfile.
You no longer need to depend on Ruby to compile your SASS.
LIBSASS has 100% parity with RUBY SASS, and doesn't come with the Ruby dependency.
If you're using grunt, you can switch over to LIBSASS by editing your gruntfile.js to use
grunt.loadNpmTasks('grunt-sass');
instead of
grunt.loadNpmTasks('grunt-contrib-sass');
You should also update your package.json file accordingly.
You can then get Azure to execute your grunt tasks as explained in this answer.

Ruby Mine complains that "Cannot switch SDK." even if the SDK is there and available

My Ruby Mine 6.0.3 gives the message:
Project .ruby-version Settings: Cannot switch SDK. RVM SDK '2.1.1#rails3' wasn't found.
I manage ruby environments with rvm.
The wanted environment seems to be ok:
rvm gemset list
gemsets for ruby-2.1.1 (found in /home/agostino/.rvm/gems/ruby-2.1.1)
(default)
global
rails3
=> testproject
Not only this, but also Mine seems to access the rvm environments quite well since opening File, Settings i can see:
So why can't it switch to the correct environment?
If, in the form above, I select it manually, it seems to work fine. But the "cannot switch..." message still appears each time I open the project.
I found for a similar problem (Rubymine 6.3.1 and Ruby 2.1.1) that I had to format .ruby-version in the following way:
ruby-2.1.1
Note the prefix 'ruby-" to the version number. I'm not sure whether this is an RVM, Ruby, Rubymine, or some other issue that caused this problem, but the fix I mentioned worked on my Mac.
I am not sure if this is the case, but you might be telling rubymine to use a different ruby version, and it uses that version on all the commands, that's why it shows the errors on each interaction with ruby.
You need to change the running configuration, from the menu choose: Run > Edit configuration
Then you'll find few settings on the left, choose the one that you use to run your project, and on the right check for Ruby SDK, choose the correct ruby version from the list, and click ok. Every thing should be fine, you might need to bundle because gems aren't shared between different ruby versions.
FYI this issue has been already reported to JetBrains RUBY-15058 and it seems they will work on adding "ruby-" prefix if missing.

Installing Ruby 1.8.7 (and other stuff) manually

I don't want to rely on the one-click installer any more, and I want to learn how to install Ruby manually. Is there a resource for this?
Download the Windows binaries for Ruby 1.8.7 here: http://www.ruby-lang.org/en/downloads/. Extract that to wherever you would like; I use C:\ruby. Then put C:\ruby\bin in your PATH environment variable.
Download the zlib package: http://www.zlib.net/zlib123-dll.zip and extract the zlib1.dll, rename it to zlib.dll and move it into your Windows\System32.
Download the iconv package: http://sourceforge.net/project/showfiles.php?group_id=25167&package_id=51458. Find and extract the iconv.dll file into your Windows\System32.
Download the rubygems package and follow the instructions, basically extracting the package and running ruby setup.rb.
Verify that everything works properly by trying a gem install rails, once that installs then do: rails test_project
Well, if you're on a Mac I'd recommend MacPorts. There's a good post on it here that's still valid.
If you're on Windows and don't want to use the one-click installer you can install Cygwin and build ruby through it. Here's a post I found.
I'd start with the one-click installer, probably by taking a good look inside the source on RubyForge (disclaimer, I haven't actually done this...). These guys clearly know how to build Ruby on Windows from source, so I'd be inclined to see how they did it.
Beyond that, did you know you can download the 1.8.7 Windows binary from the ruby-lang.org downloads page? That page also has the current stable 1.8.7 source
You might also need libeay32.dll and ssleay32.dll, found in OpenSSL: http://www.slproweb.com/products/Win32OpenSSL.html
I've pretty much concluded that Ruby 1.8.7 just isn't stable yet for Windows. I was able to get it running on one Vista machine following the instructions above but not my laptop.
For the laptop I followed the following steps and everything seems to be working so far:
Install 1.8.6 using the 1-click
installer. Let it delete old copies
of Ruby if necessary.
Install gems 1.3.4
gem install rails
ruby script\console
point browser to http://localhost:3000/. Make sure everything works as expected
stop console
extract 1.8.7 zip file into the Ruby 1.8.6 directory
copy dll files discussed above into the ruby/bin directory
restart console and again check http://localhost:3000/
I would only follow these directions as a last resort if the instructions above don't work.
Before you wag a finger at me and scold me for this approach...
please consider that I spent ~8 hours reading and trying everything possible and was able to use the approach above successfully on another computer. I'm open to other suggestions!
If you are looking for a place to get all those DLL files - here is a trick: If you install the Ruby one-click-installer for Ruby 1.8.6, it has all of those DLL files in C:\ruby1.8.6\bin (assuming you installed it there).
I was playing with the PIK gem (rvm for Windows) and ran into that problem for Ruby 1.9.1 and after copying those DLL files everything worked perfectly.
Of course, those DLL files are somewhat old, so if Ruby 1.9.1 or 1.8.7 relies on any new features in those DLL files there might be a potential for a bug, but I haven't noticed anything so far and it beats hunting down them on the Internet.

Resources