Composer with alias: Could not open input file - composer-php

I know this questions has been asked here many many times, but I couldn't find my specific case. I'm on shared hosting with SSH access on Debian. When executing the command
/usr/bin/php7.1-cli /xxxxxxxxx/www/composer.phar
it runs perfectly in any folder. When putting the same command 1:1 into an alias in bashrc like
alias composer='/usr/bin/php7.1-cli /xxxxxxxxx/www/composer.phar'
I get the "Could not open input file" error. What am I missing?
EDIT: When showing the aliases through the command "alias" in every line except one the "a" of the word "alias" is replaced by an apostrophe:
'lias composer='/usr/bin/php7.1-cli /xxxxxxxxx/www/composer.phar'

So, after changing the .bash_profile file from CR+LF to LF it is correctly processed. This didn't work with .bashrc, but this partial success is sufficient for me now.

Related

Windows PATH seems broken in Git Bash

I installed MySQL and wanted to see if it worked well, testing it on Git Bash (the course told me to do so). The code I had to write was the following one: export PATH=/c/Program Files/MySQL/MySQL Server 8.0/bin/:$PATH.
The main issue is that every time I open again Git Bash there are several lines saying not a valid identifier. I can't provide an image as I'm new, but one of the examples might be:
bash: export: `Corporation/NVIDIA': not a valid identifier
Although I deleted Git Bash and reinstalled again, the problem persists. Does anyone know how to fix that on Windows?
Thanks in advance!
Because the path contains spaces, it needs to be quoted:
export PATH="/c/Program Files/MySQL/MySQL Server 8.0/bin/:$PATH"
You need to change this in whatever file you originally wrote this line in; it's probably named .bashrc or .bash_profile and can be found in your home directory (typically c:\Users\YourUsername).

source /.bash_profile command not working

I am trying to refresh my aliases on my Mac (OS Catalina 10.15.6) after defining new aliases in my .bash_profile file with the command:
source ~/.bash_profile
But terminal keeps giving this error message:-bash: s: command not found
This is confusing because for the longest time this command worked. I even had it included in my .bash_profile file as an alias, where it worked fine.
I'm aware the problem could have to do it with an error in my PATH but I've never made any edits to my PATH so have no idea what the issue could be?
Thanks in advance.
My first instinct would be to check both ~/.bashrc, and /etc/bashrc if it exists. That is where I customarily define aliases, and it looks to me as though a bad alias may be your problem.
I'm not saying it was the one you made, although it might be. Just go through your rc and profile files and look for any aliases which might in any way clash with source.
I suspect the source command is working just fine and the problem is a bad line in the ~/.bash_profile itself that looks like it's trying to run a command named s. I would look in there for the problem.
It might help to run it with xtrace on via bash -x ~/.bash_profile – running it in a separate process like that won't have any of the presumably-desired side effects of sourceing it in your current shell, but you can see what it's trying to do so that you can fix it.
(You can also just set -x before the source and get both xtrace and running in the current shell; just be sure to set +x afterwards or your shell session will be full of debug output.)

How to properly write a bash executable file

I am having some issue in writing a simple executable .sh file via bash.
The order of operation as soon as I open a terminal (ctrl+alt+T) are:
pc:~$ roscd
pc:~/catkin_docking_ws/devel$ cd ..
pc:~/catkin_docking_ws$ cd devel/lib/tuginterface/
pc:~/catkin_docking_ws/devel/lib/tuginterface$ ./tuginterface
I have been investigating this small issue and came across this source which advises to change and rename the project as an alias and that is exactly what I tried to do:
alias proj="roscd"
alias proj2="cd .."
alias proj3="cd devel/lib/tuginterface/"
alias exec="./tuginterface"
My current executable file after many trials is:
#!/bin/bash
alias proj="roscd"
alias proj2="cd .."
alias proj3="cd devel/lib/tuginterface/"
alias exec="./tuginterface"
But it still does not work.
The same post advises to create a script and after that an alias in the startup file.
Please advise on how to solve this problem and sorry if it is a simple question but I don't seem to catch the mistake I am making.
The script doesn't need to define aliases. Aliases are commands that you can type yourself. The script can just execute the commands directly.
#!/bin/bash
cd ~/catkin_docking_ws/devel/lib/tuginterface
./tuginterface
I've combined the three cd commands into one that jumps straight to the correct directory.
"But I thought cd doesn't work in shell scripts?"
It depends what you're looking for. When a script changes directory it affects later commands in the script, so in that respect it does work. The change of directory is only inside the script, though. The person calling the script won't see the directory change. Their current directory is unaffected.

Bash alias causing error "bash: cd: too many arguments" only when set in .bashrc

I have several bash aliases set in my .bashrc but they generate errors every time I open a new terminal. Each time a new terminal opens, two bash: cd: too many arguments will appear. The aliases work as intended, but I would like to solve the errors anyway. Here are the aliases in question:
alias .1="cd .."
alias .2="cd ../.."
alias .3="cd ../../.."
alias .4="cd ../../../.."
alias .5="cd ../../../../.."
alias .=".1" #Trouble maker
alias ..=".2"
alias ...=".3"
alias ....=".4"
alias .....=".5"
I have narrowed it down to alias .=".1" as the culprit creating the errors. I understand the . is its own command and I am slapping an alias on top of it. I am not sure this is the issue or not, but I have noticed when I remove this line the errors disappear. Furthermore, running the alias on the CLI itself does not generate the same errors... only when in the .bashrc does it generate the errors.
Things I have tried:
Quotations on both sides of =
Changing alias .=".1" to alias .="cd .."
Adding a space before alias command in an attempt to suppress output
Aliasing . means you are changing how subsequent shell commands include other shell scripts. Since . and source do the same thing in bash you might be able to fix this by making sure that they're only using source. Look in .bash_profile for instance. Bash looks at a variety of files while it is starting and .bashrc is probably getting read by .bash_profile and something in there is trying to . some other file.
But really, why? Can you just add a dot to each of these and be ok with it? The .. directory is one level up so that could make it easier to remember. Changing things like this that are fundamental to how the shell operates and glues together multiple scripts is going to keep tripping you up.
The alias that is causing the error is: alias .=".1". The single period is a synonym for the source command, which reads in and executes commands from the file you pass as its argument.
What you're essentially doing (unintentionally), is trying to change the behavior of the source command using an alias.

Unix bash alias not working after start screen

Hi I am having a problem with setting alias in mac after I start the screen command, I have alias for working with git, like
commit=git commit
they work as I expect when I start my terminal (iTerm2), but then sometimes I use screen to have simultaneous instances in remotes servers and virtual machines I work with. After this the alias disappear(command not found).
Does anyone know why or how solve it?
To make the alias work, you must use the alias command. For example, to create an alias in Bash you do:
$ alias commit="git commit"
This works temporarily ie.: in your current shell. In order to make it "stick", you must put it in your ~/.bashrc. That will make it be sourced to all instances of Bash you'll invoke during your terminal session.
When you start screen, it starts a separate Bash too, so you'll be covered.
You write something about VMs. If you need this alias to work there, you must make ~/.bashrc on these VMs to have the same aliases. But that's the other story. You should already know how to achieve what you want.
You need to make sure your aliases are defined in ~/.bashrc to ensure they get included in all logins. You can test this out: edit your ~/.bashrc to include this line:
echo "bashrc"
And then edit your ~/.bash_profile to include this line:
echo "bash_profile"
You'll see when you start screen that only "bashrc" is displayed.
See this question for much more detail on the subject.

Resources