egoist / egoist/bget

rename: invalid cross-device link

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
211
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Thanks for this awesome project! 🤗
I really appreciate your free time spending on writing helpful tooling 👏🏻

Unfortunately, I had an error when I tried `bget` to install `ripgrep` for the first time. Here are the details:

```shell
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal

$ bget --version
v1.0.8/linux-amd64

$ bget BurntSushi/ripgrep -b rg -d $HOME/.local/bin
? Select an asset ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz (2.01 MB)
? Bin already exists. Overwrite? Yes
rename /tmp/4243669700/ripgrep-13.0.0-x86_64-unknown-linux-musl/rg /home/chshersh/.local/bin/rg: invalid cross-device link
```

Apparently, this happens because `bget` uses `os.Rename` and Go implements `os.Rename` using the [`rename` syscall](https://man7.org/linux/man-pages/man2/rename.2.html) which doesn't support renaming of files between different drives.

In my case, `/tmp` and `/home` directories are indeed on different drives on my Ubuntu machine:

```
$ df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p4 201G 172G 20G 91% /home

$ df -h /tmp
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p3 28G 17G 9.6G 64% /
```

I'm not sure what would be the best solution to solve this problem by `bget`. It can implement the solution in the `mv` command style by copying the file instead of renaming if files are on different drives.

* https://apple.stackexchange.com/questions/355169/how-does-the-mv-command-work-with-external-drives

In my case the workaround is to copy-paste paths from the `bget` command and replace `rename` with `mv` like this:

```shell
mv /tmp/4243669700/ripgrep-13.0.0-x86_64-unknown-linux-musl/rg /home/chshersh/.local/bin/rg
chmod +x /home/chshersh/.local/bin/rg
```

Which is less convenient but still something 🙂

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.