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

harlequin --config crashes with FileNotFoundError instead of creating new file #465

Closed
erhhung opened this issue Feb 13, 2024 · 2 comments
Closed
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@erhhung
Copy link

erhhung commented Feb 13, 2024

Describe the bug

After answering various prompts,harlequin --config crashes with FileNotFoundError instead of creating a new config file.

To Reproduce

$ harlequin --config

? What config file do you want to create or update? ~/.config/harlequin/config.toml
? What would you like to name your profile? default
? Which adapter should this profile use? postgres
? What connection string(s) should this profile use?  Separate items by a space.
? What theme should this profile use? monokai
? How many rows should the data table show? 10000
? Show local files from a directory? (Leave blank to hide)
? Show cloud storage files?  Enter bucket name or URI (or `all`), or leave blank to hide cloud storage viewer.
? What locale should Harlequin use for formatting numbers?  Leave blank to use the system locale.
? Which of the following adapter options would you like to set? done
? Would you like to set a default profile? default
 We generated the following profile:
╭─────────────────────────────╮
│ default_profile = "default" │
│                             │
│ [profiles.default]          │
│ adapter = "postgres"        │
│ theme = "monokai"           │
│ limit = 10000               │
╰─────────────────────────────╯
? Save this profile? Yes

Traceback (most recent call last):
  File "/Users/erhhung/.local/bin/harlequin", line 10, in <module>
    sys.exit(harlequin())
             ^^^^^^^^^^^
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/harlequin/cli.py", line 358, in harlequin
    cli()
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/rich_click/rich_command.py", line 125, in main
    with self.make_context(prog_name, args, **extra) as ctx:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/click/core.py", line 943, in make_context
    self.parse_args(ctx, args)
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/click/core.py", line 1408, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/click/core.py", line 2400, in handle_parse_result
    value = self.process_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/click/core.py", line 2362, in process_value
    value = self.callback(ctx, self, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/harlequin/cli.py", line 117, in _config_wizard_callback
    wizard()
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/harlequin/config_wizard.py", line 25, in wizard
    _wizard()
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/harlequin/config_wizard.py", line 165, in _wizard
    file.write(config)
  File "/Users/erhhung/Library/Application Support/pipx/venvs/harlequin/lib/python3.12/site-packages/tomlkit/toml_file.py", line 57, in write
    with open(self._path, "w", encoding="utf-8", newline="") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '~/.config/harlequin/config.toml'

Expected behavior

  • I expected a config file to be created at the path specified: ~/.config/harlequin/config.toml.
  • I expected the app to properly convert ~/ in the path to the $HOME path.
  • I expected the ~/.config/harlequin directory to be created automatically (does not currently exist).
  • I expected subsequent running of harlequin without the --config-path option to automatically read this new config file according to $XDG_CONFIG_HOME conventions.

Actual behavior

  • No directory or file was created.
  • Harlequin is not reading default config file in its $XDG_CONFIG_HOME path.

Additional context

$ harlequin --version
harlequin, version 1.15.0

Installed Adapters:
  - duckdb, version 1.15.0
  - sqlite, version 1.15.0
  - postgres, version 0.2.2

Can you tell us more about your system?

  • Shell: Bash 5.2.26(1)-release
  • Terminal: iTerm2 3.4.23
  • OS of the shell: macOS 14.2.1
  • OS of the terminal (if different from the shell):
@tconbeer
Copy link
Owner

Thanks for the report - I think this is because the parent directory did not exist; should be an easy fix.

@tconbeer tconbeer added bug Something isn't working good first issue Good for newcomers labels Feb 13, 2024
@erhhung
Copy link
Author

erhhung commented Feb 14, 2024

Thanks for the report - I think this is because the parent directory did not exist; should be an easy fix.

Actually, with the parent directory already created, it still fails with the same error. I believe Python just doesn't understand standard shell glob patterns like ~/:

GLOB_TILDE
              Carry out tilde expansion.  If a tilde ('~') is the only
              character in the pattern, or an initial tilde is followed
              immediately by a slash ('/'), then the home directory of
              the caller is substituted for the tilde.  If an initial
              tilde is followed by a username (e.g., "~andrea/bin"),
              then the tilde and username are substituted by the home
              directory of that user.  If the username is invalid, or
              the home directory cannot be determined, then no
              substitution is performed.

vyshnav-vinod added a commit to vyshnav-vinod/harlequin that referenced this issue Feb 18, 2024
@vyshnav-vinod vyshnav-vinod mentioned this issue Feb 18, 2024
vyshnav-vinod added a commit to vyshnav-vinod/harlequin that referenced this issue Feb 20, 2024
vyshnav-vinod added a commit to vyshnav-vinod/harlequin that referenced this issue Feb 21, 2024
vyshnav-vinod added a commit to vyshnav-vinod/harlequin that referenced this issue Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants