# Cannot get source using git



## sprock (Oct 19, 2021)

I'm using this command:
	
	



```
sudo git clone -b releng/12.2 --depth 1 https://git.freebsd.org/src.git 122src
```
 to get the source for 12.2-RELEASE.  It fails like this:


```
Cloning into '122src'...
fatal: unable to access 'https://git.freebsd.org/src.git/': Could not resolve host: git.freebsd.org
```

Am I using the correct command?


----------



## sprock (Oct 19, 2021)

Then I discovered that the repo name is https://git.FreeBSD.org, note the capitalisation.

Now it is working.  Sorry for the noise.


----------



## Jose (Oct 19, 2021)

Capitalization doesn't matter in DNS names. You had a DNS failure, likely because of a network problem.

```
$ ping git.freebsd.org
PING gitmir.geo.freebsd.org (149.20.1.203): 56 data bytes
64 bytes from 149.20.1.203: icmp_seq=0 ttl=54 time=3.335 ms
64 bytes from 149.20.1.203: icmp_seq=1 ttl=54 time=3.402 ms
64 bytes from 149.20.1.203: icmp_seq=2 ttl=54 time=3.391 ms
```

Why are you cloning the source as root?


----------



## sprock (Oct 19, 2021)

OK, thanks.

Why root: building in /usr/122src


----------



## SirDice (Oct 19, 2021)

sprock said:


> Why root: building in /usr/122src


Sources don't need to be checked out as root, they don't even need to be built by root. You can build it as a regular user as long as you set MAKEOBJDIRPREFIX to a directory that user can write to.


```
MAKEOBJDIRPREFIX      Defines the prefix for directory names in the tree
                           of built objects.  Defaults to /usr/obj if not
                           defined.  This variable should only be set in the
                           environment or /etc/src-env.conf and not via
                           /etc/make.conf or /etc/src.conf or the command
                           line.
```
See build(7).


----------



## grahamperrin@ (Oct 19, 2021)

sprock said:


> /usr/122src



A typo? 


```
root@mowa219-gjp4-8570p-freebsd:~ # ls -dhl /usr/src
drwxr-xr-x  27 root  wheel    44B Oct 19 22:31 /usr/src
root@mowa219-gjp4-8570p-freebsd:~ #
```


----------



## SirDice (Oct 20, 2021)

grahamperrin said:


> A typo?


Source tree can live anywhere you want.


----------



## sprock (Oct 20, 2021)

SirDice said:


> Sources don't need to be checked out as root, they don't even need to be built by root. You can build it as a regular user as long as you set MAKEOBJDIRPREFIX to a directory that user can write to.
> 
> 
> ```
> ...


Yes, I have built as a user sometimes.  No particular reason I'm not doing it that way presently.
Cheers,
sprock


----------



## sprock (Oct 20, 2021)

grahamperrin said:


> A typo?
> 
> 
> ```
> ...


No.  I have /usr/122src & /usr/122obj to distinguish them from my build of 13.0, which exists on the same host.
Cheers,
sprock


----------



## eternal_noob (Oct 20, 2021)

sprock said:


> No particular reason I'm not doing it that way presently.


As a rule of thumb: You should only work as root if absolutely necessary. Checking out source and compile it is not.


----------

