pulp icon indicating copy to clipboard operation
pulp copied to clipboard

Solver fails if TMPDIR includes a space

Open saizai opened this issue 9 months ago • 2 comments

Details for the issue

What did you do?

Run pulp with environment TMP="/Volumes/RAM Disk/"

What did you expect to see?

Results

What did you see instead?

Usage: gurobi_cl [--command]* [param=value]* filename
Type 'gurobi_cl --help' for more information.
Traceback (most recent call last):
  [redacted]
  File [redacted]
    problem.solve(pulp.GUROBI_CMD(threads=16, timeLimit=600))
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[redacted]/Python/3.13/lib/python/site-packages/pulp/pulp.py", line 1996, in solve
    status = solver.actualSolve(self, **kwargs)
  File "[redacted]/Python/3.13/lib/python/site-packages/pulp/apis/gurobi_api.py", line 494, in actualSolve
    lp.assignVarsVals(values)
    ~~~~~~~~~~~~~~~~~^^^^^^^^
  File "[redacted]/Python/3.13/lib/python/site-packages/pulp/pulp.py", line 1918, in assignVarsVals
    for name in values:
                ^^^^^^
TypeError: 'NoneType' object is not iterable

Fix

Run pulp with environment TMP="/Volumes/RAMDisk/" (no space)

See e.g. https://github.com/coin-or/pulp/blob/ebbbfdedce62a3c1815d98bbb4caada513782941/pulp/apis/gurobi_api.py#L463-L471 which fail to quote the file names. Probably true for other APIs too.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • [ ] Windows: ( version: ___ )
  • [ ] Linux: ( distro: ___ )
  • [x] Mac OS: ( version: ___ )
  • [ ] Other: ___

I'm using python version:

  • [ ] 3.7
  • [ ] 3.8
  • [ ] 3.9
  • [ ] 3.10
  • [ ] 3.11
  • [x] Other: 3.13.2

I installed PuLP via:

  • [x] pypi (python -m pip install pulp)
  • [ ] github (python -m pip install -U git+https://github.com/coin-or/pulp)
  • [ ] Other: ___ (conda?)

Did you also

  • [ ] Tried out the latest github version: https://github.com/coin-or/pulp
  • [ ] Searched for an existing similar issue: https://github.com/coin-or/pulp/issues?utf8=%E2%9C%93&q=is%3Aissue%20

saizai avatar Mar 15 '25 19:03 saizai

Is there anything we can do from the pulp side? such as escaping the paths or something? Let me know. Even better, submit a PR if you think you know how to fix it.

pchtsp avatar Mar 17 '25 15:03 pchtsp

My Python skills aren't good enough to make the PR myself, but e.g. in the lines I cite, the file names/paths should be shell-escaped and shell-quoted before being added to options on the shell cmd

saizai avatar Mar 17 '25 17:03 saizai