I've saved 'hello world' as a .rb file on my computer running Mac OS X Lion. I'm trying to create a new directory called ruby_tutorials in the root of my file system, but I'm having some trouble.
I tried typing in the command mkdir /ruby_tutorials in a terminal, but I got this error message: 'Permission Denied'. How can I overcome this?
Try this:
sudo mkdir /ruby_tutorials
sudo allows you to execute commands as a superuser. You need administrative privileges to create a directory in your root directory. One reason to use sudo for individual commands instead of always having administrative privileges is that it protects you from accidentally harming your system.
Related
I am using PowerShell on Windows 10 Pro and have installed Docker version 18.03.1-ce.
I CD into a local directory where I want to edit a set of config files to build my Jekyll webpage. I ran the following command:
docker run -e JEKYLL_NEW=true -p 80:4000 -v ${pwd}:/site bretfisher/jekyll-serve
and the the following message:
NOTE: making new jekyll site!
Conflict: /site exists and is not empty.
Ensure /site is empty or else try again with `--force` to proceed and overwrite any files.
If I use the --force flag inside the call above it tells me unknown flag. Anyone has any idea how to fix this and successfully build a jekyll container linked to my local directory of files to be able to edit and preview on localhost in the browser before pushing it into production?
Pay close attention to the steps in the Jekyll quick start. In step 3, Jekyll creates the directory for your web site. The error message is telling you that there's already an existing site directory with files in it, so Jekyll quits rather than overwrite existing files. If you delete the contents of that directory or move them elsewhere, your jekyll new command can proceed.
You might try picking a different site name, by the way. Jekyll creates its own _site directory where it puts the built HTML files for your site. You're asking for confusion when you have a site/_site directory.
I want to run a Ruby on Rails application. When I tried to run it, it shows me this,
The program 'rails' is currently not installed. You can install it by typing:
sudo apt install ruby-railties
So, I figured out the problem and I found that the problem is due to not login into bash shell. My terminal could not execute 'ruby' or 'ruby on rails' scripts. I checked .bashrc and .bash_profile files if PATH variable is set to point to rvm file.
When I did,
/bash/bin -l
it shows me ruby or rails are installed on system and I could start Rails server successfully. But if I opened another Terminal window, same problem occurs. Basically, I want to log into bash shell by default. Please correct and help me to sort out this. Thanks!
If you are sure the location of your bash shell is /bin/bash you could use this command (replacing "username" with your username):
chsh -s /bin/bash username
That will change your default shell in most unix like operating systems.
Afterwards you can verify it checking /etc/passwd where you will see the default shell at the end of the line of your username.
Warning: Try it first with a new user, in order to avoid losing your shell access if the path to bash is different :-)
I need to get access to pg_hba.conf to try and fix my broken postgres development db that gives the error on RAILS_ENV=development rails s of
PG::ConnectionBad
fe_sendauth: no password supplied
This post at least seems to suggest that such access may help: PG::ConnectionBad: fe_sendauth: no password supplied
The problem is, even though I know the path
/Library/PostgreSQL/9.3/data/pg_hba.conf
When I actually try to cd into it:
cd /Library/PostgreSQL/9.3/data/
I get: cd:cd:13: permission denied: /Library/PostgreSQL/9.3/data/
The seemingly obvious fix would be to sudo, so I try that:
sudo cd /Library/PostgreSQL/9.3/data/
And nothing happens. Literally the next line shows that I'm still exactly where I was. How can sudo be denied? And how can I either access this file or fix my issue?
Thanks!
This:
sudo cd /Library/PostgreSQL/9.3/data/
runs the cd command under sudo. sudo actually runs a new instance of the shell (/bin/sh or whatever) then runs the command in the shell.
The current directory is a property of the current process. It is inherited by new child processes, but it changes do not get propagated up to parent processes.
What you've done is the equivalent of:
sh -c 'cd /tmp'
It makes a new shell, cds to a location, then exits. The effect of the cd only affects that shell, So it effectively did nothing.
What you should do instead is use sudo to open the file in your text editor by absolute path, e.g.:
sudo nano /Library/PostgreSQL/9.3/data/pg_hba.conf
(nano is a simple and user-friendly command line text editor; I'm assuming you don't know how to use vi given this question.)
I've got a fairly simple question I guess. I'm working on a Ruby on Rails app.
I'm trying to switch to PostgreSQL thanks to Heroku.
In my database.yml file it states:
Install PostgreSQL and put its /bin directory on your path.
My question is how do I put PostgreSQL's /bin directory on my path? Exactly which file do I modify and how?
I imagine this is my issue since when I run the "rails db" command i get:
"Couldn't find database client: psql,psql.exe. Check your $PATH and try again."
Thanks everyone!
Robin.
Append the directory to system PATH (not user PATH) by Environment Variables, using a semicolon to separate it from the previous entry.
You can find it from control pannel -> system -> Advanced -> Environment Variables
Ran into the same issue and tried the solution mentioned here
[user#host user]$
psql
bash: psql: command not found
[user#host user]$
echo $PATH
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin
[user#host user]$
export PATH=$PATH:/usr/local/pgsql/bin
[user#host user]$
psql testdb
Should do the trick.
You need to install Postgres first then add the path to system properties > environment variables > in system variables section you will see PATH variable
This is my preferred way of adding a new location to the PATH environment variable (on modern Red-Hat-based systems):
echo 'export PATH="/usr/pgsql-9.3/bin:$PATH"' | sudo tee /etc/profile.d/pgsql.sh
PATH is a colon : separated list of directories that are search, in order, for a called program.
Profile configurations under /etc are persistent for all users (but require the active shell to source them to take effect).
The version number is tacked on to the PostgreSQL directory when it is installed from their repository.
I'm trying to setup a new app with postgresql so I can deploy with Heroku. However, when I run the app using 'rails server' my welcome to rails screen gives this error:
PG::Error
could not connect to server: Permission denied Is the server running
locally and accepting connections on Unix domain socket
"/var/pgsql_socket/.s.PGSQL.5432"?
I'm sure this is the same issue as is covered here:
Repairing Postgresql after upgrading to OSX 10.7 Lion
But the fix by John Wang doesn't work.
I've tried adding 'export PATH=/usr/local/bin:$PATH' to the .bash_profile, .bashrc and .zshrc, none of which change the outcome. Calling which psql always returns /usr/bin/psql.
What am I doing wrong here? Any help would be much appreciated!
edit
Running /usr/local/bin/psql gives the same error and running echo $PATH gives:
/opt/local/bin:/opt/local/sbin:/Users/dave/.rvm/gems/ruby-1.9.3-p194/bin:/Users/dave/.rvm/gems/ruby-1.9.3-p194#global/bin:/Users/dave/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/dave/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/dave/.rvm/bin
What happens if you run your locally installed psql directly?
/usr/local/bin/psql ...
If that works then it's the path you need to change. You can just try running the export in a terminal, then which psql. If that doesn't pick up the right psql then check the export worked with
echo $PATH
I'm not sure which .xxrc file you'll need to update then - not got a mac to hand I'm afraid, but at least you'll know the command will work.
Oh - I keep several different versions of PostgreSQL around and find it useful to have some aliases set up:
alias psql90='/usr/local/pgsql90/bin/psql -p 5490'
alias psql84='/usr/local/pgsql84/bin/psql -p 5484'
alias pg_dump90=...
Your $PATH is just a list of directories to check separated by ":". It starts /opt/local/bin rather than /usr/local/bin and if you look further along you'll see /usr/bin coming before /usr/local/bin. So - we need to do two things:
Find out which psql we actually want
Make sure we can edit our PATH
Firstly - find your postgresql.conf file and check what port you are running on. There are three items of interest: listen_addresses, port and unix_socket_directory. Then we'll see if there's a socket there.
ls -a <your unix_socket_directory>
You should see a "file" something like ".s.PGSQL.5432" where the 5432 is the port number from your config file. If there's no such file, it's not running and it's time to get it running. You may need to change the port number in the config file if it matches Apple's existing usage.
Then find what psql installations exist
find /usr -type f -name psql
find /opt -type f -name psql
Try and figure out which one you need, perhaps add --version to help.
Then, let's see about editing your PATH. You must have some changes in your settings file anyway, so let's see if we can find where that setting is.
grep -l 'local/bin' ~/.*rc
That should list filenames containing local/bin - have a look and see if they are editing your PATH.