yo angular generates the files in my home directory and I don't know why.
I did the following:
ppa for node
curl -sL https://deb.nodesource.com/setup | sudo bash -
then install node
sudo apt-get install -y nodejs
create a symlink
sudo ln -s "$(which nodejs)" /usr/bin/node
install yeoman
sudo npm install -g yo
sudo npm install -g generator-angular
next steps from the instruction from https://github.com/yeoman/generator-angular
mkdir my-new-project && cd $_
now I run
yo angular test1
now all the files will be created in my home directory instead of the my-new-project directory where I am currently. What did I wrong?
node -v: v0.10.36
npm -v: 2.5.1
Update1: new npm version
Solution:
yo angular looks for .yo-rc.json file in the current directory, if the file isnt there it tries to find it in the home dir. To solve this:
look for a hidden .yo-rc.json file in the home directory and delete it.
Or create an empty .yo-rc.json file in the directory you want to use.
Thanks to issue page at https://github.com/yeoman/generator-angular/issues/1037#issuecomment-83118093 the solutions was relatively easy.
After the command mkdir my-new-project && cd $_
I needed to create an empty .yo-rc.json file with {} as content to this folder.
Then I could start yo and all files are created in my my-new-project folder now.
In case anyone else stumbles on this. The reason will be that a .yo-rc.json file is in the "wrong" directory.
Delete it and all will be well.
This started happening to me after I ran yo from my home folder by mistake. Apparently I didn't clean up the generated files properly and left the ~/.yo-rc.json around. All you need to do is get rid of the .yo-rc.json in your home folder and run yo from your desired folder again.
Probably you have there .yo-rc.json file. You should delete all hidden files in home directory which yeoman created and it's should works.
you should try not to install node with sudo, that causes your troubles.
Take one instruction out of this link to install your node for usual user
Instructions and it should work.
I searched for .yo-rc.json file in the folder it wrongfully creates your project in, then showed all hidden files via "defaults write com.apple.finder AppleShowAllFiles YES" in terminal then reload Finder ( alt button + right click on finder icon) and deleted the hidden .yo-rc.json file and other hidden files that came with it. Then reloaded finder again after using the same command as above but replace YES by NO.
That did it for me !
Related
I just setup a Rails Application in my Ubuntu 18 machine, and I want to connect it to Forest Admin. However, Forest Admin requires that I set up a Node Application using npm first. The node application requires the installation of Lumber CLI tool in order to install Forest Admin.
I have however installed Lumber CLI tool by running the command below:
npm install -g lumber-cli#latest -s
When I run the command below npm lumber -version in my command line terminal, I get the response:
6.13.4
But when I try to generate the Forest Admin using the command below:
lumber generate "my_project"...
I get the following error:
Command 'lumber' not found
I need some help. Thank you.
Here's how I solved it:
The issue is because NPM does not have the write access to the directory that will contain the package you want to install (here lumber-cli).
To solve this issue, override the default directory where your global NPM packages will be stored:
mkdir ~/.npm-global
Then, configure NPM to use this directory instead of the default one:
npm config set prefix '~/.npm-global'
Then, make the node executables accessible from your PATH. To do so, export the environment variable PATH by opening or creating the file ~/.profile and add this line at the end:
export PATH=~/.npm-global/bin:$PATH
Finally, reload the ~/.profile file:
source ~/.profile
Try installing lumber cli again using the command below:
npm install -g lumber-cli#latest -s
It should be able to install lumber without any error, and also display the directory where lumber-cli is installed.
Reference: Prevent permission errors at installation
That's all
I hope this helps
I opened terminal fresh and typed.
$ python3
Then I typed quit to get out of it.
$ quit()
I then typed:
$ pip3 install splinter requests bs4
After I typed:
$ cd supbot-tut
-bash: cd: supbot-tut: No such file or directory
When I typed that I got the error code: -bash: cd: supbot-tut: No such file or directory.
I tried this dozens of times and it won't work. I do not know how to fix this problem and I am a new coder so please send exact code I have to write to fix this problem. Thank you!
Check if you're in the correct directory using pwd and see if that directory contains supbot-tut that you're trying to get into with ls.
Or you can make a directory using mkdir supbot-tut then you will be able to cd into it.
That error occurs when you try to issue the cd command and you pass a directory (a folder) that doesn't exist. Can you type the command ls and see if you see that directory listed. You can easily check with your file explorer too. Create that directory and your issue should go away.
Short question: my system user (name sharelatex) does not search in manually installed TexLive in /usr/local/texlive but search in /usr/share/texlive (I don't know why there is this folder here, I didn't install TexLive from Ubuntu repo). My another normal user and root user can search well in /usr/local/texlive. How can I force sharelatex user to search in /usr/local/texlive? Thanks!
Detail: I'm trying to install sharelatex onto my Ubuntu server.
I have manually installed TexLive using:
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xvf install-tl-unx.tar.gz
cd install-tl-*
sudo ./install-tl
While installing, I have created a system user named sharelatex and added it to group sharelatex by these 2 commands:
sudo adduser --system --home /var/www/sharelatex --no-create-home --group sharelatex
sudo chown -R sharelatex:sharelatex /var/www/sharelatex
When I login as root or normal user, the output of the command
which latex
is
/usr/local/texlive/2015/bin/x86_64-linux/latex
However,when I try to run the same command as sharelatex user:
sudo -u sharelatex which latex
the output is
/usr/bin/latex
I also think this was the problem about $PATH with system user sharelatex. Even I have tried to put my TexLive directory to /etc/environment, my sharelatex user still cannot find it. However, after take a closer look at sharelatex service files, I see that the path for sharelatex seems to be set again when sharelatex execute latex command. Here is how to fix it:
Step 1. Search for your upstart files sharelatex-SERVICE.conf where SERVICE should be replaced with web, chat,clsi,... Full list as below:
sharelatex-chat.conf
sharelatex-clsi.conf
sharelatex-docstore.conf
sharelatex-document-updater.conf
sharelatex-filestore.conf
sharelatex-real-time.conf
sharelatex-spelling.conf
sharelatex-tags.conf
sharelatex-template.conf
sharelatex-track-changes.conf
sharelatex-web.conf
If you follow the installation manual from sharelatex github, these files are probably in /etc/init.
Step 2. In each file, you will see this line:
LATEX_PATH=/usr/local/texlive/2015/bin/x86_64-linux
This line will set LATEX_PATH variable to the right TexLive. And in the ending of the file, you will see the line that will execute TexLive command:
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production PATH=$PATH:$LATEX_PATH $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
What you need to do it to swap $PATH:$LATEX_PATH to become PATH=$LATEX_PATH:$PATH. By doing this, the directory to the right TexLive will be search first.
Make this change to all the sharelatex-SERVICE.conf listed above.
After editing all those files, you might want to restart all those services (search for restart upstart services), or maybe just restart the machine.
I have Rails project. When I try to run any rake task or rails server it give me this error
env: ruby\r: No such file or directory
Could someone help me?
If you are working on a Unix / Mac, then this error is because you have incorrect line endings.
Here is a solution using dos2unix; you may need to install this program on your system. If apt is available, you can use sudo apt install dos2unix.
Set your line endings correctly, and have git manage how it handles them:
git config --global core.autocrlf input
In your directory you are going to convert all of the files by running:
find ./ -type f -exec dos2unix {} \;
This will cycle through all of your files, converting them. and solving the problem. Add your changes. Commit them, and you should be good to go.
You probably have edited ./bin/rake file and added \r at the end of first line:
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
Make sure that after "ruby" you have only new line char.
Thanks to the comments above, I solved my server issue that was caused from cloning my group's github rails app and causing localhost:3000 to fail. I was just working on the backend from my fullstack app: ruby(-v 2.7.1)/rails(-v 6.0.3.4). And these 2 people's comments solved my error:
"For those of you who got "find: ‘dos2unix’: No such file or directory" error: sudo apt install dos2unix" – RealMan Jul 26 '17 at 14:59
"Note that that find command may be excessive... this point is arguable; it may well be fine, but it may be overkill in some situations. Another possible route (for step 2 in this answer) is git rm -r --cached . followed by git reset --hard HEAD... which is likely faster (if nothing else, it won't run dos2unix on files in the .git housekeeping directory!)... This has potential gotchas as well (probably quite fine if you're running from a "clean" checkout, though), but thought I'd at least mention it." – lindes Jul 13 '19 at 0:42
I kept getting this error and finally figured out how to fix it.
I made sure all the permissions on the files in my bin folder were
executable.
Run ls -lha in your current repository. You want each file to have an x at the end like this
-rwxr-xr-x.
To achieve this, you will want to run chmod +x <file_name_here> for each file in your bin folder, such as chmod +x rails, chmod +x bundle, etc.
Now when you run ls -lha you should see that they all have an x at the end.
Next, either in SublimeText, Atom or what ever text editor you have, you will want to check that you are not using Windows line endings. The \r character is something Windows uses. Unix just uses \n for a new line.
I use Atom so I went to the plugins section (Cmd + , on Mac) and then searched for line-ending-selector in the Packages section, and then went to the line-ending-selectors settings. Change your default to 'LF'.
You will find that at the bottom of files, Atom will tell you the type of line ending the file is using with a CRLF for Windows and LF for Unix/Mac. You want all your files to use 'LF'.
So in your terminal, open each file in your bin folder in Atom, by running atom ./bin/filename (such as atom ./bin/rake).
At the bottom you will see 'CRLF' or 'LF'. If you see 'CRLF', click on it and, at the top of Atom, you can choose 'LF'.
Cmd + s to save.
Do this for each. You are basically telling your file to strip all Windows line endings and use Unix line endings instead.
Once all files are edited, you should be able to run your rake or rails command.
Note: Sublime Text and Text Mate should have equivalents to Atom's line-ending-selector.
For macOS users
Step 1: HOMEBREW_NO_AUTO_UPDATE=1 brew install dos2unix
Step 2: git config --global core.autocrlf input
Step 3: find ./ -type f -exec dos2unix {} \; (in the repo you were trying to run your task on)
git add and git commit
You are good to go!
If none of the other answers works, try this:
git config --global core.autocrlf true
rails app:update:bin
I had the same problem on Windows Terminal, using WSL 2! I followed a post that recommended to install the dos2unix dependencie: sudo apt install dos2unix (Using apt package manager) and run other two commands:
git config --global core.autocrlf input (Set your line endings correctly, and have git manage how it handles them)
find ./ -type f -exec dos2unix {} \; (In your directory you are going to convert all of the files)
The git will identify a couple of changes, but you don't need to commit it. I just made a git restore . , remove node dependencies rm -rf node_modules and download it again yarn install.
When I try to create a jhipster application in ubuntu 13.10 with yo jhipster the generated output files are always dumped in the wrong directory.
For example I run yo jhipster in the directory /mnt/mercury/jhipster-test/alpha then the files are dumped out to /mnt/mercury. In fact if I run yo jhipster in any subdirectory of /mnt/mercury they are always dumped out to /mnt/mercury.
I'm using yo version 1.1.2 from the standard ubuntu repository
Please advise how to generate files to be output in current directory.
For the benefit of anyone else facing this problem.
I managed to get Yeoman working with the following
npm cache clean
sudo npm rm -g yo
npm cache clean
sudo npm install -g yo
My problem: Accidentally "yo generating" in the parent directory.
Solution: Delete the .yo-rc.json file in the parent directory, then running the yo generator command in the child directory.
As discussed in the comments, this is a Yeoman problem on Ubuntu 13.10:
We don't have this issue with Ubuntu 12.04
There is the same issue with other generators ("yo webapp") on Ubuntu 13.10
As a workaround, I recommend you have a look at our Docker container:
https://github.com/jhipster/jhipster-docker
This will allow you to run the full JHipster stack, with Ubuntu 12.04, inside a container! Just use it to generate the app, then you can work directly on your host machine.
On Mac OSX Maverick with Node v0.10.26, yo v1.1.2 and generator-jhipster v0.11, the yo hipster command was generating all the sources always in the same (wrong!) directory and not using my current directory.
I fixed this problem doing the following:
cd <WRONG_DIR_WHERE_CODE_IS_CREATED>
rm .yo-rc.json node_modules/
npm uninstall -g karma
npm install -g karma (Note: using sudo it was not working!)
sudo npm install -g generator-jhipster
Not sure why but I've then been able to install karma and generator-jhipster again and suddenly yo hipster starting generating code again in my current directory
Could it be caused by different environment variables when launching npm with sudo?
The file .yo-rc.json is hidden, if it is not deleted, the generator will constantly take the settings from it. You must delete .yo-rc.json.