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

[4.6.0b0] MalformedVersionError #7776

Closed
dhirschfeld opened this issue Sep 18, 2018 · 18 comments · Fixed by #7780
Closed

[4.6.0b0] MalformedVersionError #7776

dhirschfeld opened this issue Sep 18, 2018 · 18 comments · Fixed by #7780
Labels
locked [bot] locked due to inactivity source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type
Milestone

Comments

@dhirschfeld
Copy link
Contributor

Since 4.6.0b0 didn't seem to work with my conda build I attempted to downgrade to the latest stable but got an error!

λ conda install conda=4.5.11
Collecting package metadata: failed

MalformedVersionError: Malformed version string '~': invalid character(s)
@dhirschfeld
Copy link
Contributor Author

dhirschfeld commented Sep 18, 2018

Some debug output:

<snip>
DEBUG conda.core.solve:solve_final_state(212): solving prefix C:\Miniconda3
  specs_to_remove: frozenset()
  specs_to_add: frozenset({MatchSpec("conda=4.5.11")})
  prune: False
Collecting package metadata: ...working... TRACE conda.gateways.disk.test:file_path_is_writable(25): checking path is writable C:\Miniconda3\pkgs\urls.txt
DEBUG conda.core.package_cache_data:_check_writable(252): package cache directory 'C:\Miniconda3\pkgs' writable: True
failed
Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 38, in __call__
    return cls._cache_[arg]
KeyError: '~'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 38, in __call__
    return cls._cache_[arg]
KeyError: '~'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\conda\exceptions.py", line 987, in __call__
    return func(*args, **kwargs)
  File "C:\Miniconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
    exit_code = do_call(args, p)
  File "C:\Miniconda3\lib\site-packages\conda\cli\conda_argparse.py", line 81, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File "C:\Miniconda3\lib\site-packages\conda\cli\main_install.py", line 21, in execute
    install(args, parser, 'install')
  File "C:\Miniconda3\lib\site-packages\conda\cli\install.py", line 250, in install
    force_reinstall=context.force_reinstall or context.force,
  File "C:\Miniconda3\lib\site-packages\conda\core\solve.py", line 107, in solve_for_transaction
    force_remove, force_reinstall)
  File "C:\Miniconda3\lib\site-packages\conda\core\solve.py", line 145, in solve_for_diff
    force_remove)
  File "C:\Miniconda3\lib\site-packages\conda\core\solve.py", line 235, in solve_final_state
    ssc = self._collect_all_metadata(ssc)
  File "C:\Miniconda3\lib\site-packages\conda\core\solve.py", line 285, in _collect_all_metadata
    index, r = self._prepare(prepared_specs)
  File "C:\Miniconda3\lib\site-packages\conda\core\solve.py", line 667, in _prepare
    self.subdirs, prepared_specs)
  File "C:\Miniconda3\lib\site-packages\conda\core\index.py", line 204, in get_reduced_index
    push_record(prefix_rec)
  File "C:\Miniconda3\lib\site-packages\conda\core\index.py", line 190, in push_record
    combined_depends = record.combined_depends
  File "C:\Miniconda3\lib\site-packages\conda\models\records.py", line 314, in combined_depends
    result = {ms.name: ms for ms in MatchSpec.merge(self.depends)}
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 443, in merge
    match_specs = tuple(cls(s) for s in match_specs if s)
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 443, in <genexpr>
    match_specs = tuple(cls(s) for s in match_specs if s)
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 50, in __call__
    return super(MatchSpecType, cls).__call__(**parsed)
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 172, in __init__
    self._match_components = self._build_components(**kwargs)
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 381, in _build_components
    return frozendict(_make_component(key, value) for key, value in iteritems(kwargs))
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 381, in <genexpr>
    return frozendict(_make_component(key, value) for key, value in iteritems(kwargs))
  File "C:\Miniconda3\lib\site-packages\conda\models\match_spec.py", line 395, in _make_component
    matcher = _implementors[field_name](value)
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 40, in __call__
    val = cls._cache_[arg] = super(SingleStrArgCachingType, cls).__call__(arg)
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 486, in __init__
    vspec_str, matcher, is_exact = self.get_matcher(vspec)
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 557, in get_matcher
    self.matcher_vo = VersionOrder(vspec_str)
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 40, in __call__
    val = cls._cache_[arg] = super(SingleStrArgCachingType, cls).__call__(arg)
  File "C:\Miniconda3\lib\site-packages\conda\models\version.py", line 179, in __init__
    raise MalformedVersionError(vstr, "invalid character(s)")
conda.models.version.MalformedVersionError: Malformed version string '~': invalid character(s)

@dhirschfeld
Copy link
Contributor Author

Instrumenting self.depends from the failing MatchSpec.merge:

@property
def combined_depends(self):
from .match_spec import MatchSpec
result = {ms.name: ms for ms in MatchSpec.merge(self.depends)}
result.update({ms.name: ms for ms in MatchSpec.merge(
MatchSpec(spec, optional=True) for spec in self.constrains or ()
)})
return tuple(itervalues(result))

...gives me:

################################################################################
# self.depends = ('appdirs ~=1.4.3', 'python 3.6.*', 'pytz', 'setuptools', 'six ~=1.10')
################################################################################

@dhirschfeld
Copy link
Contributor Author

dhirschfeld commented Sep 18, 2018

I was eventually able to downgrade by patching the function to replace ~= with >= 😌

...though it doesn't seem to be functional :/

@kalefranz
Copy link
Contributor

Do you know what package that was?

@kalefranz kalefranz added type::bug describes erroneous operation, use severity::* to classify the type source::community catch-all for issues filed by community members severity::1 blocker; broken functionality with no workaround labels Sep 18, 2018
@kalefranz kalefranz added this to the 4.6.0 milestone Sep 18, 2018
@dhirschfeld
Copy link
Contributor Author

Sorry, I'm not sure - I probably should have printed repr(self) too I guess.

I'm currently still trying to install 4.5.11 - after upgrading conda doesn't seem to like downgrading again :/

@dhirschfeld
Copy link
Contributor Author

Let me know if you need more debug info and I can try and reproduce since my current env is basically stuffed :|

@kalefranz
Copy link
Contributor

What channels were you using at the time? And what platform?

And I hear you on the downgrade thing. I do want the ratcheting effect that you're running into for the general case, but we need to provide an escape hatch for users like you :)

@kalefranz
Copy link
Contributor

I can't figure out where these ~= operators are coming from. I originally thought this was probably related to #7761, but now it doesn't appear so. This is happens when directly reading repodata it appears, so those operators must actually be used in packages somewhere.

@kalefranz
Copy link
Contributor

While I'd still like to understand where the ~= was coming from, I think #7780 should take care of everything here. Including a new config parameter allow_conda_downgrades (for now undocumented).

@mariusvniekerk
Copy link

~= is almost certainly from some pip installed thing?

@jorisvandenbossche
Copy link

jorisvandenbossche commented Sep 18, 2018

Not sure it is helpful (it is a different error message, and I also can't further debug at the moment), but I ran into a similar issue last week when conda updated to 4.6.

I got the following when trying to go back to 4.5:

(base) joris@joris-XPS-13-9350:~/scipy$ conda install conda=4.5
Collecting package metadata: / WARNING conda.core.index:push_record(193): Skipping conda-forge/linux-64::ipywidgets-5.2.3-py27_0 due to InvalidVersionSpecError: ==1.*
WARNING conda.core.index:push_record(193): Skipping conda-forge/linux-64::ipywidgets-5.2.3-py36_0 due to InvalidVersionSpecError: ==1.*
WARNING conda.core.index:push_record(193): Skipping conda-forge/linux-64::ipywidgets-5.2.3-py35_0 due to InvalidVersionSpecError: ==1.*
done
Solving environment: failed

InvalidVersionSpecError: Invalid version spec: ==1.*

It seemed that if I removed conda-forge and conda-canary channels from my condarc file, the problem went away and I could downgrade conda again / install other packages again.

@kalefranz
Copy link
Contributor

@jorisvandenbossche The bulk of what you're seeing should just be warnings, but I don't know why your environment failed to solve. Can you provide the output of conda install conda=4.5 -vv?

@kalefranz
Copy link
Contributor

kalefranz commented Sep 18, 2018

Ok, here's the PEP definition for the ~= operator: https://www.python.org/dev/peps/pep-0440/#compatible-release

@kalefranz
Copy link
Contributor

There's also ===, which we never implemented support for.

@dhirschfeld
Copy link
Contributor Author

dhirschfeld commented Sep 18, 2018

@jorisvandenbossche ipywidgets should be fixed:

conda-forge/ipywidgets-feedstock#51

@jorisvandenbossche
Copy link

That seems to be the case, as I can no longer reproduce it!

@dhirschfeld
Copy link
Contributor Author

FWIW the culprit was fs:

PrefixRecord(
    name='fs',
    version='2.0.24',
    build='pypi_0',
    build_number=0,
    channel=Channel("pypi"),
    subdir='pypi',
    fn='fs-2.0.24.dist-info',
    depends=('appdirs ~=1.4.3', 'python 3.6.*', 'pytz', 'setuptools', 'six ~=1.10'), 
    constrains=(),
    package_type='virtual_python_wheel',
	<snip>
)

@github-actions
Copy link

github-actions bot commented Sep 7, 2021

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants