question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Glob fails to link if there's only one file

See original GitHub issue

When I try to use glob with only one file in the source directory, dotbot fails to create the link with “Nonexistent source for…”

- defaults:
    link:
      relink: true
      glob: true
      force: true
- link:
    ~/.config/broot: broot/*
.
├── broot
│   └── conf.hjson
❯ ./install 
Nonexistent source for ~/.config/broot : /home/jay/dotfiles/broot/*

==> Some tasks were not executed successfully

Adding a second file without changing anything else makes it function as expected. I would expect it to behave the same regardless of how many files are in the dir.

Why bother using glob if there’s only one file? Because it means if I add a second file later, I don’t need to also edit my install.conf.yaml. Almost always, I just want to symlink whatever is in the source directory. It took some squinting to even identify what was going wrong.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
eengstromcommented, Jun 2, 2021

I can confirm this with a new test case I created, and that it worked as of the last tagged version (v.1.19.0), and failed after a patch (that I wrote) was merged into master. I will develop a fix.

1reaction
eengstromcommented, Jun 3, 2021

I have a fix of a sort - line 73 of link.py goes from:

                elif len(glob_results) == 1 and destination[-1] != '/':

to

               elif len(glob_results) == 1 and (glob_results[0] == path):

… but I’m not sure the reason one would want to specify glob: true and yet not use any glob meta-chars. Essentially, the entire elif stanza seems like it hides errors in usage and tries to guess the/a right thing to do. The immediately preceding stanza does the same thing, but throws an error if the result is a directory.

Unless there is a clear use-case for allowing the use of glob: true and source path specifications without any glob meta-chars, I’d suggest always throwing an error.

I suppose the possible use case is when people want to put glob: true into a defaults block, but then again, the code is still hiding errors in use that aught to be corrected.

Looking for feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

glob.glob does not return any files in a fully qualified path?
This appears to be a bug in the "Evaluate expression" feature of pycharm : nothing is found there. Running the same code within...
Read more >
path/filepath - Go Packages
Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the...
Read more >
glob expansion suddenly not working properly in loops
It seems this is only a problem when there is an extremely large number of files. I ran this command on the same...
Read more >
glob - Greg's Wiki
"Glob" is the common name for a set of Bash features that match or expand specific types of patterns. Some synonyms for globbing...
Read more >
fast-glob - npm
It's a very fast and efficient glob library for Node.js. ... Throw an error when symbolic link is broken if true or safely...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found