Bash profile messed up? - ruby-on-rails

When trying to install Ruby on Rails using railsinstaller.org they messed up my system a bit after I uninstalled it and now my terminal prints this every time I start a new terminal up:
Last login: Fri Mar 1 15:01:45 on console
-bash: /etc/profile.d/sm.sh: No such file or directory
-bash: /etc/profile.d/rvm.sh: No such file or directory
I checked my .bash_profile and it doesn't reference anything like that. Any ideas of what's up and how to fix it?
I'm running Mac OS X by the way...

Usually the shell sources a lot of files during startup and these are common locations that come to my mind:
~/.bashrc
~/.profile
/etc/profile
/etc/profile.d/*

Related

Ghostscript installed but not found RGhost::Config::GS[:path]='/path/to/my/gs'

I've been trying for a few hours now solve this problem and I looked everywhere for a solution and I did not find one. I'm trying to run a spec test for my project and I have the following error coming up:
RuntimeError:
Ghostscript not found in your system environment (linux-gnu).
Install it and set the variable RGhost::Config::GS[:path] with the executable.
Example: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style
RGhost::Config::GS[:path]="C:\\gs\\bin\\gswin32c.exe" #windows-style
And I do try to put RGhost::Config::GS[:path]='/usr/local/bin/gs' and it returns:
bash: RGhost::Config::GS[:path]=/usr/local/bin/gs: No such file or directory
but ghostscript is installed, I did everything (make, sudo make install, etc etc) and when I run gs -v it returns:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
When I use the user interface and search for "gs" in the "Files" application, it is found in /home/marcelle/projects/ghostscript-9.26/bin/gs and I also tried:
RGhost::Config::GS[:path]='/home/marcelle/projects/ghostscript-9.26/bin/gs'
and it returns the same error:
bash: RGhost::Config::GS[:path]=/home/marcelle/projects/ghostscript-9.26/bin/gs: No such file or directory
I also tried to delete ghostscript from my notebook with autoremove and purge and installed it again using what I mentioned before (./configure, make, sudo make install), restarted the notebook, the terminal and nothing.
PS: I'm using Ubuntu 20.04.
I managed to figure out a solution. Looking for the code for the Rghost, what I saw in its spec is that the path expected was different than the path the ghostscript really is.
When I run whereis or which on my terminal, it returns:
which gs
/usr/local/bin/gs
So I was trying to point to this path. But seeing the spec test for Rghost which I found on github for Rghost, we can see that it expects /usr/bin/gs:
it 'should detect linux env properly' do
RbConfig::CONFIG.should_receive(:[]).twice.with('host_os').and_return('linux')
File.should_receive(:exists?).with('/usr/bin/gs').and_return(true)
RGhost::Config.config_platform
RGhost::Config::GS[:path].should == '/usr/bin/gs'
end
So it expects /usr/bin and not /usr/local/bin.
Then I just copied to that path and the spec ran with no problems anymore:
sudo cp /usr/local/bin/gs /usr/bin
I've no experience with Ruby at all, but I also got this error when using asciidoctor, which uses rghost for the PDF generation.
The command RGhost::Config::GS[:path]='/path/to/my/gs' mentioned in the error is not a shell command, which is why bash couldn't handle it. However, to me it wasn't immediately clear what to do with this command either. I expected an easy way to set this variable somewhere, but couldn't find it.
What worked for me was searching the rghost.rb file, which is where this variable is set and can be changed. In Windows, it was located in C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\rghost-0.9.7\lib\rghost.rb.
In this file, I added the following line, which solved the problem:
RGhost::Config::GS[:path]="C:\\Program Files\\gs\\gs9.55.0\\bin\\gswin64c.exe"
NB: the mentioned paths can be different for everyone, so make sure to use that paths that are valid for your system.

Unison command not found

Recently my Unison application has stopped working on my Mac terminal saying the command cannot be found. Not sure if this was the reason but I recently reinstalled brew (which is how it was installed), which may have broken it.
Here is the error output:
mac:~ Imran$ unison sites
-bash: unison: command not found
I can see that if I locate unison unison is found in the following directories:
> /Users/Imran/unison.log /Users/Imran/unison.tar.gz
> /usr/local/Cellar/unison /usr/local/Cellar/unison/2.40.102
> /usr/local/Cellar/unison/2.40.102/COPYING
> /usr/local/Cellar/unison/2.40.102/INSTALL_RECEIPT.json
> /usr/local/Cellar/unison/2.40.102/NEWS
> /usr/local/Cellar/unison/2.40.102/README
> /usr/local/Cellar/unison/2.40.102/TODO.txt
> /usr/local/Cellar/unison/2.40.102/bin
> /usr/local/Cellar/unison/2.40.102/bin/unison
> /usr/local/Library/Formula/unison.rb
> /usr/local/Library/LinkedKegs/unison /usr/local/bin/unison
> /usr/local/opt/unison /usr/share/zsh/5.3/functions/_unison
Can someone help me get this working again? I suspect its something to do with the link to the app being broken.
If you've done a reinstall of a brew cask, you may need to manually link it again if it can't be found on your path
brew link unison
I had the same issue when trying to use Unison from Windows to Mac (where it has been installed with Brew).
You can give an explicit path for the unison executable on the server by using the command-line option
-servercmd /full/path/name/of/unison
or adding
servercmd=/full/path/name/of/unison
to your profile
Source
According to the documentation the error message bash: unison: command not found means:
Make sure Unison is installed on the host you are trying to connect to.
For anyone running into this error on macOS:
If you're using zsh (or running a newer macOS version where zsh is the default) you have to modify or create ~/.zshenv.
Add your path to the shell environment by adding one of the following snippets to ~/.zshenv.
For ARM64 (M1 Macs):
eval $(/opt/homebrew/bin/brew shellenv)
or on x86 (Intel Macs)
eval $(/usr/local/bin/brew shellenv)
or you simply source your zshrc:
source ~/.zshrc
Your user's PATH variable does not include a link to the unison binary.
Add /usr/local/Cellar/unison/2.40.102/bin/unison to your .bashrc,
$ vi ~/.bashrc
add the following,
export PATH=$PATH:/usr/local/Cellar/unison/2.40.102/bin/unison
save and quit, and then re-read your users bashrc file,
exec bash
Now try which unison again, or actually just try running it with,
$ unison

Atom linter-erb failing with "Error: /usr/bin/env: ruby: No such file or directory"

I have the linter set to check on save and it throws this error every time I save a .erb file. In the settings for the package I have both the following settings specified:
Erb Executable Path
/home/jason/.rvm/rubies/ruby-2.3.0/bin/erb
Ruby Executable Path
/home/jason/.rvm/rubies/ruby-2.3.0/bin/ruby
I was having a similar issue with the linter-ruby package, but setting the ruby executable path seemed to fix it. Here's what my path looks like:
$ echo $PATH
/home/jason/.nvm/versions/node/v5.10.0/bin:/home/jason/.rvm/gems/ruby-2.3.0/bin:/home/jason/.rvm/gems/ruby-2.3.0#global/bin:/home/jason/.rvm/rubies/ruby-2.3.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/jason/.rvm/bin:/home/jason/.rvm/bin
Here's the full output of the error.
Error: /usr/bin/env: ruby: No such file or directory
at parameters.exit (/home/jason/.atom/packages/linter-erb/node_modules/atom-linter/lib/helpers.js:47:27)
at triggerExitCallback (/opt/atom/resources/app.asar/src/buffered-process.js:213:47)
at /opt/atom/resources/app.asar/src/buffered-process.js:220:18
at Socket.<anonymous> (/opt/atom/resources/app.asar/src/buffered-process.js:98:18)
at emitOne (events.js:82:20)
at Socket.emit (events.js:169:7)
at Pipe._onclose (net.js:469:12)
It seems even though I've specified where it should be looking for ruby, it's still looking in /usr/bin/env.
Here's a bit more output that's hopefully helpful:
$ which erb
/home/jason/.rvm/rubies/ruby-2.3.0/bin/erb
$ which ruby
/home/jason/.rvm/rubies/ruby-2.3.0/bin/ruby
I'm not sure this would have any effect, but for the sake of trying to cover all my bases, I also have this in ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
Ubuntu: 15.10
kernel: 4.2.0-34
Atom: 1.6.0
linter-erb: 1.0.2
I've restarted Atom several times but the error keeps popping up. Any help would be much appreciated.
EDIT
I found that if I start Atom from the terminal, I don't have this problem, but when I launch it from the icon in the launcher, the issue crops up again.
Try pointing the linter to RVM wrappers instead of direct binaries in RVM which work OK only in interactive shells. RVM wrappers make the binaries run correctly even in other environments and shells.
Simply choose a wrapper directory under $HOME/.rvm/wrappers/ for your desired version of ruby and gemset and use the binaries from there.
See this answer for more explanation.

Automatically Run Command Upon Opening Terminal (Linux Mint 16)

I am using Rails and for some reason unbeknownst to me I have to execute the following line every time I start the terminal in order to use ruby and rails.
source ~/.bash_profile
If I type the following before running the above command, it will recommend that I install the packages (ie "type 'sudo apt-get install package' to install")
rails -v && ruby -v && irb -v
Is there a way to make my terminal execute a command upon opening? Or, better yet, can anybody help explain the reason I have to run this line? I found an article that said I had to do that given my issue but it didn't explain why.
Assuming you're using the bash shell, then ~/.bash_profile will be sourced once (and only once) when you log in to the system but not each time you open a terminal window.
The ~/.bashrc, however, will be sourced every time a new shell is opened (i.e. when you open a terminal window).
So they are probably some environment variables settings in ~/.bash_profile which are required for ruby to run. Those settings should be moved to the ~/.bashrc file instead so they are defined in all shell instances.
Alternatively, source ~/.bash_profile from your ~/.bashrc (this is at your own risk, it may have side-effects).

RVM not found, after installing RVM

I've found a couple similar posts regarding this same problem, but none of the solutions seem to apply, here.
On a fresh Ubuntu 10.10 install, I follow the instructions for installing RVM:
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then I create .bash_profile and add the following line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
I restart the terminal and check RVM:
$ type rvm | head -1
-bash: type: rvm: not found
As the RVM installation guide explains to do so, I replaced the first line (below) in .bashrc with the second one, then indented everything in the rest of the file and added a fi.
[ -z "$PS1" ] && return # original
if [[ -n "$PS1" ]]; then # replaced with this
Restarted terminal and still, no luck.
Then, I removed the line I added to .bash_profile in the beginning and added it to .bashrc, even though that isn't what the guide said to do. Still, no luck. I also entered it directly on the command line, with no change in behavior. When I run .rvm from ~/.rvm/bin/rvm it complains that there is no such file or directory as /.rvm/scripts/rvm and that the command was not fund.
Of course, there isn't any such "scripts" directory inside of ./rvm, either -- so I'm not sure why it's looking for one? The only directories inside of .rvm are
archives
bin
config
gems
gemsets
log
man
rubies
src
tmp
user
The only thing I've found while googling for answers are other people complaining of similar problems and people telling them to add the instructed line to .bash_profile (which I obviously already did). At this point, I have nothing more to go on and am at an impasse.
Regards.
Resolution:
As Andrew Marshall advised in his comments, below, I did an 'rm -rf .rvm' and reinstalled rvm. I had actually attempted this two times before posting here, with the same results every time. No odd messages in the install log, but no /scripts/ directory, either. Just so I could say I had, I did it a third time at Andrew's urging. This time, I checked and the /scripts/ directory existed. Running 'type rvm | head -1' confirmed it as a 'function' and I can now move on.
Make sure that you restart a session after reinstalling, so that rvm is in your path.
You can try to logout/login.
You can also open your shell as a login shell. Under ubuntu 12.04:
Open a terminal
Edit > Profile Preferences
Under tab Title and Command, check run Command as a login shell
Open new terminal (ctrl+alt+t) and type rvm
If there's no scripts directory inside .rvm, it would seem that RVM failed to successfully complete installation. Delete the .rvm directory, try reinstalling, and look at the installation output closely to see if it's complaining about anything.

Resources