-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix #369 relative command path #508
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
base: main
Are you sure you want to change the base?
Conversation
if program.startswith('/'): | ||
filename = program | ||
else: | ||
filename = os.path.join(self.config.directory, program) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the documentation says If it is relative, the supervisord’s environment $PATH will be searched for the executable.
, but this code assumes the program is relative to the configuration file directory, which is a very different thing. It introduces new behaviour that does not match the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but '/' in program
does not mean it IS NOT a relative path(or IS absolute). Only program.startswith('/')
means absolute path? If so, this code doesn't not comply with the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but your change fixes one bug and introduces another. Where in the docs does it say that a program should be found relative to the config file dir?
It seems to me the correct way to fix the issue is to change this line:
if "/" in program:
To this:
if program.startswith('/'):
Or, even better:
if os.path.isabs(program):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't introduce another bug, for self.config.directory
is the directory option in the program's config section, not the config file(supervisord.conf) dir. But isabs
can be a better choice when checking absolute path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right, my bad. Sorry. Indeed self.config.directory
is the "directory" program config option, not the directory of the config file. I withdraw my objection!
+1
+1 this, but agree that it's worth using |
Any chances to get this PR merged? |
#648 is an alternate version of this pull request with some tweaks. |
@mnaberez - I understand it was kind of a "duplicate" but the code was cleaned up and ready to be merged based on feedback here, and it really wasn't. I also just added two tests to ease the mind. I think merging the new one and closing this one would have been perfectly appropriate since I can't update this pull request without the original author of this pull request merging my code. About #508:
About #648:
As you can see the code isn't really duplicate. if "/" in program:
- filename = program
+ if program.startswith('/'):
+ filename = program
+ else:
+ filename = os.path.join(self.config.directory, program)
+
try:
st = self.config.options.stat(filename)
except OSError: - if "/" in program:
+ if os.path.isabs(program):
filename = program
try:
st = self.config.options.stat(filename)
except OSError:
st = None
-
else:
path = self.config.options.get_path()
+ # Search the root config directory of this program if it's set and is absolute.
+ if self.config.directory is not None and os.path.isabs(self.config.directory):
+ path.insert(0, self.config.directory)
+
found = None
st = None
for dir in path |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a simple bugfix,a PR which not merged,i meet the shit three years after. |
Do the maintainers of this project really think this problem is meaningless?? Long time passed, nothing improved. |
Oh yes .. plz merge it. Wasted half an hour of my life ;-) |
The docs say:
This fixes relative path like to/programname as stated in #369 .