Problems with CakePHP shell in Ubuntu 14.04 - cakephp

could somebody explain why this:
sudo Console/cake
works when I am inside path/to/cakeproject/app while this:
sudo cake
absolutely does NOT work whe I am inside path/to/cakeproject/app/Console?
Actually, understanding this would be simply a first step for me to understand why I can run sudo Console/cake when I am in the right directory (app), but I cannot run sudo cake anywhere even after modifying the PATH variable following these steps. If someone knows any possible causes for this already, please also feel free to share your thoughts.
PS: About when I said "I cannot run sudo cake anywhere", this is the error I get:
sudo: cake: command not found

I had the same problem.
You just need to install "php5-cli" to make it works.
$ sudo apt-get install php5-cli
Then try again with "cake" in your console.
$ cake
It should work.

Related

Brew error: Could not symlink, path is not writable

When I try to install a library with homebrew (brew install aLibrary), I got the following error:
Could not symlink lib/pkgconfig/aFile
/usr/local/lib/pkgconfig is not writable.
What should I do?
There are several questions and answers (1,2,etc.) concerning this brew error, this is an attempt to make a general question as suggested here.
As explained here by Rick:
Start with brew doctor which will show you errors with your brew setup.
You might see something like this: "Warning: /usr/local/lib/pkgconfig isn't writable."
It will give you the advice that: "You should probably chown /usr/local/lib/pkgconfig".
This means: sudo chown -R $(whoami) /usr/local/lib/pkgconfig
Then you will need to link the files with this: brew link yourLibrary
If this does not work hopefully the output of brew doctor will give you enough to continue the search.
Giant Elk had a great suggestion and this is how I fixed my issue, which in my opinion is the cleanest. Users should not change permissions unless they know the ramifications.
Output your installed packages (via brew) to a text file:
brew list > brewlist.txt
Uninstall brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Re-install brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Re-install previous packages (edit list if you do not need all packages):
brew install $(< brewlist.txt )
Use the following.
$ brew doctor
message will display error links to prune. If any found, run next option.
$ brew prune
once these are removed, proceed to link them agian
$ brew link python
I uninstalled brew, re-installed, then the issues went away.
You should simply give the permission to your account by running this command on terminal.
sudo chown -R $(whoami) (path)
In your case:
sudo chown -R $(whoami) lib/pkgconfig/aFile /usr/local/lib/pkgconfig

Executing commands in a series in ubuntu terminal

Suppose I have a set of commands to be executed in ubuntu terminal:
for eg:
sudo apt-get update
sudo install xrdp
sudo install java
.....
and many others.
Is it possible in ubuntu to execute the file containing these commands and execute without human intervention (like yes/no) , by default yes?
I tried installing wine , executing $wine cmd /c Commands.bat , after putting all these commands in .bat file but getting errors "Application tried to create a window, but no driver could be loaded."
So, is there any simple way of executing a series of commands in ubuntu?
What you are talking about - multiple commands in one file - is called a "shellscript".
Let's say you have commands.sh:
sudo apt-get update
sudo install xrdp
sudo install java
Then you could execute the commands using:
bash commands.sh
You can also make a directly executable shellscript out of it using the so called shebang mechanism.
Put this line on the very top (line 1) of commands.sh
#!/bin/bash
.. and make the file executable:
chmod +x commands.sh
Now you can execute it directly:
./commands.sh
If you want to say "yes" to all questions, you can use the yes command:
yes | bash "file_with_commands.sh"
No need to do something convolutied and as insane as trying to make cmd.exe work. You already got a perfectly fine working shell on your system. Also you need to understand what programs like sudo do.
sudo is not some magic chant that enables something. sudo is a helper program that allows to start a program with elevated rights. Instead of having a chain of sudo this sudo that you can as just let sudo start a shell and pass a script with all those commands to the shell.
Turning
sudo apt-get update
sudo install xrdp
sudo install java
Into
sudo sh -c 'apt-get update ; install xrdp ; install java'
However that doesn't look right. I think you originally meant to write
sudo apt-get update
sudo apt-get install xrdp
sudo apt-get install java
You can shorten this to
sudo apt-get update
sudo apt-get install xrdp java
Or in coalesced single liner shell
sudo sh -c 'apt-get update ; apt-get install xrdp java'
Now regarding the Yes/No questions. If a program you want to run unattended doesn't offer an option to give a default answer you can make use of the yes program. Even it being named yes it can also answer NO or anything you like:
narfi /home/dw
1007 ~ % yes Hello
Hello
Hello
Hello
Hello
Hello
…
How does this work? There's a concept called the "Standard Input / Output" from which programs read input from and write output to. Shells allow you to redirect the output from one program into the input of another one. This is called pipe-ing. The special character | designates a pipe in shells.
So say you've got a program that wants to see a large number of Aye inputs you could make the following call to the shell
yes Aye | happypirate
So you can combine this with apt-get to give all default yes answer writing
yes | apt-get install …
However this is barking up the wrong tree. Have a look at the call options for apt-get:
~ % apt-get --help
apt 0.9.7.6 for amd64 compiled on Oct 16 2012 18:23:06
Usage: apt-get [options] command
apt-get [options] install|remove pkg1 [pkg2 ...]
apt-get [options] source pkg1 [pkg2 ...]
apt-get is a simple command line interface for downloading and
installing packages. The most frequently used commands are update
and install.
…
-y Assume Yes to all queries and do not prompt <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
…
apt-get gives you an option to auto-answer all yes to all it questions. Neat, right? Note that other programs may use different option keys so you're well advised to always read their fine manuals (RTFM).
At its most basic level, you want to eecute a script. You do that by creating a file like this:
#!/bin/bash
sudo apt-get update
sudo install xrdp
sudo install java
Save that as a file called go, then in the Terminal, you need to make it executable like this:
chmod +x go
Then you can run it by typing:
./go
If your program expects an answer of "yes" for the first question, then "no" for the next question, you can prepare the answers in advance like this and send them into the program:
( echo yes; echo no ) | sudo apt-get update

npm / yeoman install generator-angular without sudo

I tried to install generator-angularjs using Yo (Yoeman) without sudo:
npm install -g generator-angular
I get:
Error: EACCES, mkdir '/usr/lib/node_modules/generator-angular'
When I type in sudo yo, yo tells me that I should not use sudo (which is perfectly understandable).
I have a ~/node_modules directory - why doesn't yo install its packages there?
Generators are designed to be installed globally. Otherwise, you always have to install the generator you're about to use in each project, which is unnecessarily painful. Also, you don't get to see the lovely yo menu which lists you all the available generators (unless of course, you install them all locally):
Setting up npm for global installation
So, how do we get npm to install packages globally? As you correctly said, you should never, ever run yo with sudo. There are lots of different solutions to this problem and you can spend hours discussing their pros and cons religiously.
I personally dislike installing my user packages into the global /usr/ folder. /usr/ is for software that is shared across all users on the computer. Even if it's only using the machine, there are still good reasons to respect the way the Unix file system hierarchy is designed. For example if you decide at one point to wipe your whole node installation.
My preferred way of enabling npm to install packages globally without breaking out of $HOME is to set a local node prefix. This is as easy as running
echo 'prefix = ~/.node' >> ~/.npmrc
in your local shell. After that, you want to adjust your $PATH, to point to the new installation destination for global node executables by adjusting your favorite shell's config. E.g. by adding
export PATH="$PATH:$HOME/.node/bin"
to your ~/.bashrc. After that, you can happily run npm install -g generator-angular without sudo, without running into permission conflicts and if something is completely broken and you want to start from scratch, all you need to do is remove your ~/.node directory.
Thanks to #passy I managed to finally get this working on ubuntu 13.04 (in case anyone is having similar set up issues) with the following :
sudo apt-get update
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
trying to run:
npm install -g yo
resulted in
Error: EACCES, mkdir '/usr/lib/node_modules/yo'
Fixed using:
echo prefix = ~/.node >> ~/.npmrc
echo 'export PATH=$HOME/.node/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
Running:
yo webapp
resulted in:
Error: EACCES, permission denied '/home/username/.config/configstore/update-notifier-yo.yml'
Fixed using:
sudo chown yourusername:yourusername /home/yourusername/.config/configstore/update-notifier-yo.yml
hi in my case (on ubuntu 12.04), the prefix addition in ~/.npmrc did not changed anything.
if so, build the node package by yourself and install it in /opt/node or /home/user/.node.
I had an almost identical error involving a rogue .yo-rc.json file in my root directory from a project I installed earlier. Yeoman was switching cwd from the installation dir to root dir half way through the installation, but was only outputting the EACCESS permissions error without any details that the installation directory was /. It took ages to figure out why this was, and involved debugging through the Yeoman source, but I eventually learned that Yeoman will look up through the directory tree until it finds a .yo-rc.json, and generate the code there by calling chdir to the new location.
Yeoman should maybe check that the user has write permissions for the directory. Alternatively, it could mention in the output either that the cwd has changed, or print the name of the installation directory if where it finds .yo-rc.json is different than cwd.
The command for finding rogue .yo-rc.json files
sudo find / -name .yo-rc.json
From yoeman getting started page appears the command:
yo doctor
In my case, $NODE_PATH (which in my case, Ubuntu 14.04, is defined in /etc/profile.d) isn't the same than npm root. Adding in npm root in $NODE_PATH solve the problem.
I have been trying to get yeoman to play nice with my vagrant box and this is what I had to do to install npm packages globally without sudo on ubuntu:
1. Create the directory to store global packages
$ mkdir "${HOME}/.npm-packages"
2. Tell npm where to put any packages installed globally
Insert this snippet into your ~/.npmrc file:
prefix=${HOME}/.npm-packages
3. Make sure that npm can locate installed binaries et cetera
Insert this snippet into your .bashrc/.zshrc:
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
// `unset` `manpath` to allow inheritance from `/etc/manpath` with
// the `manpath` command
unset MANPATH // remove this line if you have previously modified `manpath`
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
4. Run the following or restart terminal
$ source ~/.bashrc
Hope this helps anyone who finds themselves in a similar situation.

How can I uninstall an apache2 module?

It looks like I installed the wrong version of the module using apxs2.
Once it's disabled (a2dismod), how do I remove it so I can install the correct version?
Seems elementary, yet...somehow...I'm finding nothing on Google, IRC, etc.
It's so simple nobody has written it down yet. You just remove the .so file from /usr/lib/apache2/modules/.
And if you want to be thorough, remove anything that might be in: /usr/share/doc/module-name
For some modules on Ubuntu you can use apt-get.
To find the installed module sudo dpkg -l | grep apache.
To remove sudo apt-get purge {module_name}.
For example:
sudo apt-get purge libapache2-mod-php7.0 libapache2-mod-php5
The apache modules can be found in
/usr/lib64/apache2
or
/usr/lib64/httpd

Lost ability to run as sudo following MacPorts upgrade

I recently updgraded MacPorts from 1.9.2 to 2.0.3. Since then, I've lost the ability to run as sudo.
sudo: can't stat /opt/local/etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
Unsure if these are related, but I'm wondering what the best course of action is at this point.
port installed returns
sudo #1.7.4p2_0
sudo #1.7.7_0 (active)
Further investigation suggests I've installed MacPorts' sudo without an accompanying /opt/local/etc/sudoers file. I've managed to create such a file using visudo, copying the content of /etc/sudoers, chmod to 0440 and ownership to root:wheel.
I guess the question now is whether I should use MacPorts' sudo or uninstall it? And how did I end up with installing the MacPorts' sudo?
Not a Mac man myself, but have a look at this page:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/sudoers.5.html
...and also a look at the man page for visudo, which is used to edit the sudoers file:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/visudo.8.html#//apple_ref/doc/man/8/visudo

Resources