在VDS服务器安装Git执行sudo make install时遇Missing seperator错误
Hey there, let's sort out this Makefile issue you're facing! That *** missing separator. Stop. error is a classic gotcha with Makefiles—they're super picky about syntax, and your current file isn't following the rules Make expects.
What's Wrong With Your Current Makefile?
Your Makefile has this line:
make configure ./configure --prefix=/usr/local
This isn't valid Makefile syntax for two big reasons:
- Makefiles require a clear target-dependency-command structure, not just a random string of commands.
- Any actual command in a Makefile must start with a Tab character (spaces won't work—this is the #1 cause of that separator error). Also, you've mashed two separate commands into one line, which isn't how Make works.
Solution 1: Fix Your Makefile
If you really want to use a Makefile for this process, here's the correct way to write it (pay close attention to the Tab indents!):
# Target to install Git install: # First run the configure script with your desired prefix ./configure --prefix=/usr/local # Compile the source code make # Install to the system path (requires sudo) sudo make install
⚠️ Critical note: Each line starting with ./configure, make, and sudo make install must start with a single Tab—not spaces. Make will throw that separator error if you use spaces here.
Solution 2: Skip the Makefile Entirely (Easier!)
Honestly, you don't even need a Makefile for this. You can just run the commands directly in your terminal, which is simpler and avoids syntax headaches:
# First, install required build dependencies (prevents compilation errors) sudo apt update && sudo apt install build-essential libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev # Run the configure script to set up installation options ./configure --prefix=/usr/local # Compile the Git source code make # Install Git to your system sudo make install
Quick Check After Installation
Once it's done, verify Git is installed correctly by running:
git --version
You should see the latest version number pop up!
内容的提问来源于stack exchange,提问作者G'ofur N

