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

Filetype association in Windows registry requires double-quotes to properly handle files with spaces #290

Open
2 tasks done
mrclary opened this issue Dec 18, 2024 · 3 comments
Labels
type::bug describes erroneous operation, use severity::* to classify the type

Comments

@mrclary
Copy link

mrclary commented Dec 18, 2024

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

Double-clicking a file associated with the Spyder application does not get opened if the file path or name contains spaces.
The correct behavior is exhibited if the file name and path do not contain spaces.

Conda Info

active environment : base
    active env location : C:\Users\rclary\AppData\Local\spyder-6
            shell level : 1
       user config file : C:\Users\rclary\.condarc
 populated config files : C:\Users\rclary\AppData\Local\spyder-6\.condarc
                          C:\Users\rclary\.condarc
          conda version : 24.5.0
    conda-build version : not installed
         python version : 3.11.9.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake
                          __conda=24.5.0=0
                          __win=0=0
       base environment : C:\Users\rclary\AppData\Local\spyder-6  (writable)
      conda av data dir : C:\Users\rclary\AppData\Local\spyder-6\etc\conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/label/spyder_rc/win-64
                          https://conda.anaconda.org/conda-forge/label/spyder_rc/noarch
                          https://conda.anaconda.org/conda-forge/label/spyder_dev/win-64
                          https://conda.anaconda.org/conda-forge/label/spyder_dev/noarch
                          https://conda.anaconda.org/conda-forge/label/spyder_kernels_rc/win-64
                          https://conda.anaconda.org/conda-forge/label/spyder_kernels_rc/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Users\rclary\AppData\Local\spyder-6\pkgs
                          C:\Users\rclary\.conda\pkgs
                          C:\Users\rclary\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\rclary\.conda\envs
                          C:\Users\rclary\AppData\Local\spyder-6\envs
                          C:\Users\rclary\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.5.0 requests/2.32.3 CPython/3.11.9 Windows/10 Windows/10.0.19045 solver/libmamba conda-libmamba-solver/24.9.0 libmambapy/1.5.8
          administrator : False
             netrc file : None
           offline mode : False

Conda Config

==> C:\Users\rclary\AppData\Local\spyder-6\.condarc <==
auto_update_conda: False
notify_outdated_conda: False
env_prompt: [spyder]({default_env})
register_envs: False
channel_priority: flexible
channels:
  - conda-forge/label/spyder_rc
  - conda-forge/label/spyder_dev
  - conda-forge/label/spyder_kernels_rc
  - conda-forge
repodata_fns:
  - repodata.json

==> C:\Users\rclary\.condarc <==
auto_activate_base: False
envs_dirs:
  - ~/.conda/envs
channel_priority: flexible
channels:
  - conda-forge
  - conda-forge/label/spyder_rc
  - conda-forge/label/spyder_kernels_rc
  - C:/Users/rclary/.conda/conda-bld
  - defaults
show_channel_urls: True
conda-build:
  root-dir: ~/.conda/conda-bld
  pkg_format: 2
  zstd_compression_level: 19

Conda list

# packages in environment at C:\Users\rclary\AppData\Local\spyder-6:
#
# Name                    Version                   Build  Channel
archspec                  0.2.3              pyhd8ed1ab_0    conda-forge
boltons                   24.0.0             pyhd8ed1ab_1    conda-forge
brotli-python             1.1.0           py311hda3d55a_2    conda-forge
bzip2                     1.0.8                h2466b09_7    conda-forge
ca-certificates           2024.8.30            h56e8100_0    conda-forge
certifi                   2024.8.30          pyhd8ed1ab_0    conda-forge
cffi                      1.17.1          py311he736701_0    conda-forge
charset-normalizer        3.4.0              pyhd8ed1ab_1    conda-forge
colorama                  0.4.6              pyhd8ed1ab_1    conda-forge
conda                     24.5.0          py311h1ea47a8_0    conda-forge
conda-libmamba-solver     24.9.0             pyhd8ed1ab_0    conda-forge
conda-package-handling    2.4.0              pyha770c72_1    conda-forge
conda-package-streaming   0.11.0             pyhd8ed1ab_0    conda-forge
distro                    1.9.0              pyhd8ed1ab_0    conda-forge
fmt                       10.2.1               h181d51b_0    conda-forge
frozendict                2.4.6           py311he736701_0    conda-forge
h2                        4.1.0              pyhd8ed1ab_1    conda-forge
hpack                     4.0.0              pyhd8ed1ab_1    conda-forge
hyperframe                6.0.1              pyhd8ed1ab_1    conda-forge
idna                      3.10               pyhd8ed1ab_1    conda-forge
jsonpatch                 1.33               pyhd8ed1ab_1    conda-forge
jsonpointer               3.0.0           py311h1ea47a8_1    conda-forge
krb5                      1.21.3               hdf4eb48_0    conda-forge
libarchive                3.7.7                hedcc2b0_1    conda-forge
libcurl                   8.10.1               h1ee3ff0_0    conda-forge
libexpat                  2.6.4                he0c23c2_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libiconv                  1.17                 hcfcfb64_2    conda-forge
liblzma                   5.6.3                h2466b09_1    conda-forge
liblzma-devel             5.6.3                h2466b09_1    conda-forge
libmamba                  1.5.8                h3f09ed1_0    conda-forge
libmambapy                1.5.8           py311h0317a69_0    conda-forge
libsolv                   0.7.30               hbb528cf_0    conda-forge
libsqlite                 3.47.2               h67fdade_0    conda-forge
libssh2                   1.11.1               he619c9f_0    conda-forge
libxml2                   2.13.5               he286e8c_1    conda-forge
libzlib                   1.3.1                h2466b09_2    conda-forge
lz4-c                     1.10.0               h2466b09_1    conda-forge
lzo                       2.10              hcfcfb64_1001    conda-forge
mamba                     1.5.8           py311h8cb466b_0    conda-forge
menuinst                  2.1.2           py311hda3d55a_1    conda-forge
openssl                   3.4.0                h2466b09_0    conda-forge
packaging                 24.2               pyhd8ed1ab_2    conda-forge
platformdirs              4.3.6              pyhd8ed1ab_1    conda-forge
pluggy                    1.5.0              pyhd8ed1ab_1    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pycosat                   0.6.6           py311he736701_2    conda-forge
pycparser                 2.22               pyh29332c3_1    conda-forge
pysocks                   1.7.1              pyh09c184e_7    conda-forge
python                    3.11.9          h631f459_0_cpython    conda-forge
python_abi                3.11                    5_cp311    conda-forge
reproc                    14.2.5.post0         h2466b09_0    conda-forge
reproc-cpp                14.2.5.post0         he0c23c2_0    conda-forge
requests                  2.32.3             pyhd8ed1ab_1    conda-forge
ruamel.yaml               0.18.6          py311he736701_1    conda-forge
ruamel.yaml.clib          0.2.8           py311he736701_1    conda-forge
setuptools                75.6.0             pyhff2d567_1    conda-forge
tk                        8.6.13               h5226925_1    conda-forge
tqdm                      4.67.1             pyhd8ed1ab_0    conda-forge
truststore                0.10.0             pyhd8ed1ab_0    conda-forge
tzdata                    2024b                hc8b5060_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_1    conda-forge
urllib3                   2.2.3              pyhd8ed1ab_1    conda-forge
vc                        14.3                ha32ba9b_23    conda-forge
vc14_runtime              14.42.34433         he29a5d6_23    conda-forge
vs2015_runtime            14.42.34433         hdffcdeb_23    conda-forge
win_inet_pton             1.1.0              pyh7428d3b_8    conda-forge
xz                        5.6.3                h208afaa_1    conda-forge
xz-tools                  5.6.3                h2466b09_1    conda-forge
yaml-cpp                  0.8.0                h63175ca_0    conda-forge
zstandard                 0.23.0          py311h53056dc_1    conda-forge
zstd                      1.5.6                h0ea2cb4_0    conda-forge

Additional Context

The menu json file contains the directive

"command": ["{{ PREFIX }}/Scripts/spyder.exe", "%*"]

When the file associations are created in the Windows registry, the command appears as

C:\Users\rclary\AppData\Local\spyder-6\envs\spyder-runtime\Scripts\spyder.exe %* %1

If I modify the registry command to %* "%1", then double-clicking files with spaces will open in Spyder.
It seems that %1 is appended by menuinst and this must be double-quoted in order to work.
I've tried "%*" and %1 without success, so it seems %* is ineffective (quoted or not), but "%1" must be present in order to work.

See spyder-ide/spyder#22844

@mrclary mrclary added the type::bug describes erroneous operation, use severity::* to classify the type label Dec 18, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in 🧭 Planning Dec 18, 2024
@mrclary
Copy link
Author

mrclary commented Dec 18, 2024

Also, changing the json directive to "\"%1\"", menuinst seems to strip the " and still uses just %1 in the registry.

@mrclary
Copy link
Author

mrclary commented Dec 19, 2024

Pinging @jaimergp

@mrclary
Copy link
Author

mrclary commented Dec 19, 2024

The magic appears to happen here:

menuinst/menuinst/utils.py

Lines 159 to 171 in 903ae24

@classmethod
def quote_string(cls, s: Sequence[str]):
"""
quotes a string if necessary.
"""
# strip any existing quotes
s = s.strip('"')
# don't add quotes for minus or leading space
if s[0] in ("-", " "):
return s
if " " in s or "/" in s:
return '"%s"' % s
return s

I wonder if line 169 can be modified to read if " " in s or "/" in s or "%" in s:.
I've tested this with my application and it does remedy my issue, but I don't know if there are adverse ramifications for other applications...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::bug describes erroneous operation, use severity::* to classify the type
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant