-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix repl crash when deno dir doesn't exist #2727
Conversation
tools/repl_test.py
Outdated
@@ -137,6 +143,18 @@ def test_lexical_scoped_variable(self): | |||
self.assertEqual(err, '') | |||
self.assertEqual(code, 0) | |||
|
|||
def test_missing_deno_dir(self): | |||
current_deno_dir = os.environ["DENO_DIR"] | |||
missing_deno_dir = os.path.join(current_deno_dir, 'missing_deno_dir') |
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 is just any path that doesn't exist, right? Rather than a subdirectory of the current DENO_DIR (which is a bit confusing) can you just do something like some_path_that_doesnt_exist
?
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.
Since the path does get created by the current (fixed) code when the repl exits, I wanted to make sure the path was somewhere that creating it wouldn't be a problem.
cli/repl.rs
Outdated
match self.history_file.parent() { | ||
Some(ref parent) => fs::create_dir_all(parent), | ||
None => Ok(()), | ||
}?; |
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.
Rather than create the directory, maybe just print a warning and skip the save?
I think I'd prefer to keep all the directory creation in the deno_dir.rs module - this is repl.rs - so doesn't seem appropriate here.
Thanks for this fix BTW, it has been annoying me too. |
I think @bartlomieju suggested creating the dir if it doesn't exist when trying to save. How about moving the actual creation code into deno_dir and then calling it from repl? |
Analogously: |
I think you can just print a warning and skip saving the history. |
Will do |
Not sure if it's my fault the builds are failing but it looks like networking issues? :s |
@crabmusket try adding empty commit to reset CI |
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.
LGTM
Oh sh!t I was going to rebase some of those commits haha. Well, happy to have contributed! 🎉 |
Fixes #2719