I searched everywhere to find the .gemrc file specification but I haven't succeed.
Does anyone know where I can find it?
gem looks for a configuration file .gemrc in your home directory, although you can specify another file on the command-line if you wish (with the --config-file modifier).
There are three things you can specify in the configuration file:
command-line arguments to be used every time gem runs
command-line options for ’’RDoc’’ (used when generating documentation)
GEM_PATH settings
More at gem environment command doc.
'Home' is a Linux/Mac term. What is refers to is the folder where a user's settings appear. You can find out where your settings directory is by doing the following:
on Unix/Linux, open a terminal and type the following command:
echo $HOME
on Windows, open a command-prompt and type the following command:
echo %USERPROFILE%
For me (in Windows 7), this is C:\Users[name]. However, looks like Ruby doesn't set up your .gemrc in that folder by default. Instead, you have to create the file. Open a text editor, copy the YAML style code you need (documentation), and save the file as .gemrc in your home directory (make sure you select all files, not '.txt').
These settings will only affect that individual user. If it's your personal computer, however, you probably don't need to change the settings for all users.
An updated gemrc specification is available at RubyGems Guides (under 'gem environment'). Note that /etc/gemrc applies to all users, while ~/.gemrc applies to an individual.
If the key is a gem command (for example, install:), it specifies arguments to be used with that command.
Here are the other keys that can be specified:
:sources: A YAML array of remote gem repositories to install gems from
:verbose: Verbosity of the gem command. false, true, and :really are the levels
:update_sources: Enable/disable automatic updating of repository metadata
:backtrace: Print backtrace when RubyGems encounters an error
:gempath: The paths in which to look for gems
All of the answers here at time of writing are wrong because the obnoxious website keeps changing. It is at this moment here:
https://guides.rubygems.org/command-reference/#gem-environment
Obviously you should expect it to change constantly at this point.
Related
I'm clear on the rules rubocop follows to find the config file or files it uses to build up the list of cops it uses -- it is explained here: RuboCop Configuration
However, the rules allow for several different possibilities, and what I am looking for would be some way to get rubocop to display the path(s) of the file(s) it has found to use.
For example, if I edit a file that I think is the active rubocop config file, but find out when I run rubocop that the change I've made isn't incorporated (ergo rubocop must not be getting its config from there after all, or it's being overridden somewhere else) then it would help to know which file(s) rubocop is in fact getting its config from.
Ideally there would be a command option like rubocop --display_config_paths, which would display the path or paths of all config files it will use as currently invoked -- but given that such an option doesn't exist, is there any way to find this out?
Short Answer:
Add debug option when calling rubocop then you will see config files loaded:
$ rubocop --config ~/.rubocop.yml --debug zpl/bin/zpl_csv
configuration from /home/user/.rubocop.yml
Default configuration from
/home/lcs/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rubocop-1.25.1/config/default.yml
Inspecting 1 file`
...
Others things:
Take a look to 'Config file locations' paragraph from rubocop documentation, and check priority of configs files, note the following sentence:
'then RuboCop will use the config as specified inside the first of the following files'
If you want to use several files you may have to use 'Inheriting from another configuration file in the project'
I have added Sublime's directory to the system path, so when I enter "subl" in comman promot it opens the Sublime, that's fine. But,
When I tried to open a ruby gem, I remembered the command used in Linux etc which is "bundle open xyz", I entered this command to Windows 7's command prompt it gave me an error as "To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR".
I assumed that I must mention that i wanna open it through sublime, so I edited the command as "subl bundle open sass", but it opened a new file named ''bundle open sass'' in sublime (not the sass gem).
Does anyone know how to open a ruby gem in sublime or whatever editor from command prompt in Windows?
Thank You!
Edit: After pdobb's answer I created a variable named EDITOR in my environment variables, and set its value to subl (I assumed that the path is not needed along the "subl" because its path is already set in the path variable), but now its showing the error as "Could not locate gemfile", but when I list my gems its there.
Here is the snapshot of how I set the EDITOR variable.
The command is bundle open xyz, as you've said. The editor you want to use is set in the $EDITOR or $BUNDLER_EDITOR environment variable. In effect, bundler checks this environment variable for what editor to open the gem in. So, you just need to set the environment variable $EDITOR to subl. This is done in the same place as where you set your $PATH environment variable. See here for a guide.
you can go to the directory where the gem is installed and open the directory with your editor.
For example,
If the ruby gems are installed on .rvm/ruby-2.1.0/gems/. Let's say, you want to open 'capybara' gem. then open the .rvm/ruby-2.1.0/gems/capybara in your editor
I recently installed homebrew-cask and one of the things that I see is that it installs applications by default into the following directories:
Versioned package downloads => /opt/homebrew-cask/Caskroom/
Example : /opt/homebrew-cask/Caskroom/pdftk/2.02
Application binaries/libraries => /opt/
Example : /opt/pdftk/bin/
Instead of using the /opt directory, I would really like to use a directory located in /usr/local which is where my homebrew installation resides.
I can see from the docs that I can set an environment variable for #1, but I can't seem to figure out where to change #2.
I'd like to have the above two settings go to:
/usr/local/Caskroom/packages/pdftk/2.02
/usr/local/Caskroom/pdftk/bin
Any ideas on how I can change both settings or are there good ideas why I wouldn't want to do this?
Thanks.
From the Caskroom manual (specifically the Usage manual) you can change where the actual application will be installed by adding a line like this to your .bash_profile or .zshenv etc.
# Specify your defaults in this environment variable
export HOMEBREW_CASK_OPTS="--appdir=/Applications --caskroom=/usr/local/Caskroom"
I was having some trouble installing the gem libv8. Apparently I need to have python installed. I installed Python and was attempting to update my path with command from another forum:
SET PATH=C:[Ruby Directory]\bin;C:[Python Directory]
or in my case:
SET PATH=C:\Ruby192\bin;C:\Python27
I am not strong with paths and I can't figure out what I did. Now my environment can't find my Ruby directory.
Can someone explain what I did and how I might fix it?
That is most likely because your PATH variable already had a bunch of stuff that you simply throwed away with that line:
echo %PATH%
# a bunch of stuff
SET PATH=C:\Ruby192\bin;C:\Python27
echo %PATH%
# C:\Ruby192\bin;C:\Python27
You can try to append to it instead instead:
set PATH=%PATH%;C:\Ruby192\bin;C:\Python27
echo %PATH%
# a bunch of stuff plus C:\Ruby192\bin;C:\Python27
This change will be avalid for your terminal session only. Closing it and open again should restore the default path. If you need to make it permanent, you need to change your path throught the windows (for example, following this instructions)
So I installed Ruby On Rails using the Windows Installer.
Now the startup guides says I have to start up an Terminal and run the Rails command to make a project. I don't have a terminal, so how do I execute a Rails command and make a project??
The CMD command line in Windows does not recognize "rails"
I don't think it is an PATH problem, because when I'm in the "Bin" directory, there is "rails.bat" and "rails" with no extension. If I run Rails.bat I get "The filename, directory name, or volume label syntax is incorrect."
I get that message with whatever Argument I pass to it.
It seems to be a bug in the rails.bat file because of double-quotes, like:
#"ruby.exe"" "%~dpn0" %*
Remove the double quotes:
http://sepitfalls.blogspot.com/2008/12/updateing-rubygems-broke-gem-command.html
To get a terminal
Start > Run... or Windows key + R
Type "cmd" and hit enter.
To add a folder to the command line's path
On Windows XP (Vista is similar)
Start > Control Panel > System
Click the "Advanced" tab
Click "Environmental Variables"
Under "System Variables" double click on Path and edit accordingly.
You will need to open a new command line in order to get the updated path to take affect. With XP, I've had to reboot to force it to take affect but it shouldn't be necessary.
The Path variable is a semi-colon seperated list of folders in which the Command Line or "terminal" looks for commands.
You'll probably have to find the rails command yourself. I would try looking for a rails.bat or rails.cmd file.
I think they mean the command window. Try running it from a command line.
I dont know where the Windows Ruby on Rails intaller places its files, but the ultimately solution is that you need to make sure that the "rails" command is is your PATH - which you can view/modify by right-clicking My Computer, selecting Properties, going to the Advanced tab and then clicking on "Environment Variables" and then scrolling down until you see "PATH" and adjusting it accordingly. You probably need to find the directory where the "rails" command lives and append to the end of the existing PATH entry, inserting a ";" before you enter the new path to append it to the existing PATH.
So find where "rails" is and add its directory to your PATH.
You probably have to change your PATH in Windows to point to wherever the rails executable has been installed.
The PATH environment variable is used to determine where Windows looks for stuff; when you type, for instance, 'calc' Windows will hunt through its PATH and eventually find and run C:\Windows\calc.exe. In your case, the PATH doesn't include the directory you need, so Windows isn't searching in that directory for rails.exe when you type "rails."
To fix this, right click on "My Computer" -> "Properties" -> "Advanced" -> "Environment Variables" and then modify the PATH one to include the directory your rails.exe is in.
I recommend using cygwin for Rails development on windows - far too much of the community is using *nix. If you install the development tools package you'll automatically have svn, git and other doo-dads that you'll eventually need relating to various rails plugin installation. If you want to deploy using capistrano the installation is identical to all the instructions you find. Plus other tips and tricks people will reference will work exactly the same for you as it does for them, whereas some things are different for native windows and all the accessory tools have to be installed separately.