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.

[Bug] tilde ~ in override value will not work

See original GitHub issue

🐛 Bug

Description

tilde (~) at the beginning of the value results in hydra.errors.OverrideParseException

Checklist

  • I checked on the latest version of Hydra
  • I created a minimal repro (See this for tips).

To reproduce

** Minimal Code/Config snippet to reproduce **

python main.py hydra.run.dir=~/outputs

** Stack trace/error message **

LexerNoViableAltException: hydra.run.dir=~/outputs
                                         ^
See https://hydra.cc/docs/next/advanced/override_grammar/basic for details

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

Expected Behavior

work without error.

System information

  • Hydra Version : 1.0.6
  • Python version : 3.6
  • Virtual environment type and version : pyenv 1.2.21
  • Operating system : linux ubuntu 16.04.3 LTS

Additional context

None.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
omrycommented, Jun 1, 2021

If you are expecting hydra.run.dir=~/outputs to expand to your home directory, this is a function of the shell. You can try to echo it and see if your shell does it or not:

$ echo hydra.run.dir=~/outputs
hydra.run.dir=~/outputs
~ $ echo ~/outputs
/Users/omry/outputs

As you can see, my shell (bash) is not expanding ~ in the middle of a string. This has nothing to do with Hydra.

The reason you are getting an error from Hydra is that ~ is a special character for Hydra as well and it can’t appear in an unquoted string. Since both Hydra and your shell will intercept quotes, you need to quote twice:

$ python my_app.py 'hydra.run.dir="~/outputs"'

However, because ~ is not expanded by the shell the output directory created will actually contain the ~ character.

1reaction
dave-epsteincommented, Jul 10, 2021

Alright. I used value interpolation as a cumbersome workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tilde Slash Paths Not Working in MVC 4 - Stack Overflow
The workaround is to use Razor comments instead of HTML comments. I.e., replace <!-- Here's your comment--> with @* Here's your comment *@...
Read more >
How to replace tilde and wildcard characters in Excel?
1. Select the range where you will replace the tilde or wildcard characters, and press Ctrl + H keys to open the Find...
Read more >
Removing tilde from attribute table - GIS Stack Exchange
I am trying to remove the tilde from a few fields in my ArcGIS Pro attribute tables. I was given a few .txt...
Read more >
How to escape the tilde '~' and other special characters in ...
The following lists the Progress special characters that are escaped using the tilde including the tilde itself. All the items listed below ...
Read more >
Tilde (~) not recognized by Excel? | MrExcel Message Board
when i use VLOOKUP to look up what is in Col B for 'sky~net', i get an '#N/A' error. Looks like the tilde...
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