Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkgs.fetchgit, nix-prefetch-git fail when given a URL whose basename contains @ #103747

Closed
lilyball opened this issue Nov 13, 2020 · 2 comments
Closed
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: fetch

Comments

@lilyball
Copy link
Member

Describe the bug
If I have a URL to a git repository whose basename contains @, both pkgs.fetchgit and nix-prefetch-git fail when given this URL. This is because both of these use the basename of the URL as the default name of the checkout to copy to the store.

This can be worked around by passing the name arg to pkgs.fetchgit and using the --out flag to nix-prefetch-git, but this is often not doable when using other tools that use nix-prefetch-git internally (see nixcloud/dep2nix#19 for an example).

These tools should just sanitize @ by default, along with any other characters that are invalid in store names, perhaps by replacing those invalid characters with _.

To Reproduce
Steps to reproduce the behavior:

> git init foo@bar
Initialized empty Git repository in /Users/lilyball/Dev/Nix/Scratch/gittest/foo@bar/.git/
> ( cd foo@bar && git commit --allow-empty -m 'empty' )
[master (root-commit) ead6415] empty
> nix run nixpkgs.nix-prefetch-git -c nix-prefetch-git --url file://$PWD/foo@bar/
Initialized empty Git repository in /private/tmp/git-checkout-tmp-weHMwQDl/foo@bar/.git/
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 137 bytes | 137.00 KiB/s, done.
From file:///Users/lilyball/Dev/Nix/Scratch/gittest/foo@bar
 * branch            HEAD       -> FETCH_HEAD
Switched to a new branch 'fetchgit'
removing `.git'...
error: The path name 'foo@bar' is invalid: the '@' character is invalid. Path names are alphanumeric and can include the symbols +-._?= and must not begin with a period. Note: If 'foo@bar' is a source file and you cannot rename it on disk, builtins.path { name = ... } can be used to give it an alternative name.

Expected behavior
It should sanitize the synthesized name such that it's valid to use as a store name.

Notify maintainers
@bennofs

Metadata

  • system: "x86_64-darwin"
  • host os: Darwin 19.6.0, macOS 10.15.7
  • multi-user?: yes
  • sandbox: relaxed
  • version: nix-env (Nix) 2.3.8
  • channels(lilyball): ""
  • channels(root): "nixpkgs-21.03pre250093.0da76dab4c2"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: [fetchgit, nix-prefetch-git]
# a list of nixos modules affected by the problem
module:
@stale
Copy link

stale bot commented Jun 4, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 4, 2021
@Artturin Artturin mentioned this issue Mar 29, 2022
13 tasks
@roberth
Copy link
Member

roberth commented Apr 5, 2022

Fixed in #166383

@roberth roberth closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: fetch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants