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

Fix repl crash when deno dir doesn't exist #2727

Merged
merged 8 commits into from Aug 8, 2019

Conversation

@crabmusket
Copy link
Contributor

commented Aug 5, 2019

Fixes #2719

@CLAassistant

This comment has been minimized.

Copy link

commented Aug 5, 2019

CLA assistant check
All committers have signed the CLA.

@@ -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')

This comment has been minimized.

Copy link
@ry

ry Aug 5, 2019

Collaborator

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?

This comment has been minimized.

Copy link
@crabmusket

crabmusket Aug 5, 2019

Author Contributor

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(()),
}?;

This comment has been minimized.

Copy link
@ry

ry Aug 5, 2019

Collaborator

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.

@ry

This comment has been minimized.

Copy link
Collaborator

commented Aug 5, 2019

Thanks for this fix BTW, it has been annoying me too.

@crabmusket

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2019

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?

@nayeemrmn

This comment has been minimized.

Copy link
Contributor

commented Aug 6, 2019

DenoDir constructs DiskCache instances for deps and gen which get passed to the SourceFileFetcher and TsCompiler respectively. When caching, these invoke DiskCache::set() which creates the required parent directories on demand if they don't already exist.

Analogously: DenoDir should have a member history_file with type LogFile or something which gets passed to the Repl. When saving the history, it would invoke LogFile::append() which would behave similarly to DiskCache::set().

@ry

This comment has been minimized.

Copy link
Collaborator

commented Aug 6, 2019

I think you can just print a warning and skip saving the history.

@crabmusket

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2019

Will do

@crabmusket

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2019

Not sure if it's my fault the builds are failing but it looks like networking issues? :s

@bartlomieju

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2019

@crabmusket try adding empty commit to reset CI

crabmusket added some commits Aug 8, 2019

@ry

ry approved these changes Aug 8, 2019

Copy link
Collaborator

left a comment

LGTM

@ry ry merged commit 520bdb6 into denoland:master Aug 8, 2019

3 checks passed

Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla Contributor License Agreement is signed.
Details
@crabmusket

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2019

Oh sh!t I was going to rebase some of those commits haha. Well, happy to have contributed! 🎉

@crabmusket crabmusket deleted the crabmusket:issue/2719-repl-crash branch Aug 8, 2019

@piscisaureus piscisaureus referenced this pull request Aug 9, 2019

Merged

v0.14.0 #2754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.