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

Unable to rename file adding the .yml to the end on Windows #44

Closed
FilBot3 opened this issue Jun 30, 2016 · 5 comments
Closed

Unable to rename file adding the .yml to the end on Windows #44

FilBot3 opened this issue Jun 30, 2016 · 5 comments

Comments

@FilBot3
Copy link

FilBot3 commented Jun 30, 2016

Attempting to create a Jira task, I run into the following error when executing jira create -i Request

C:\Users\user01
λ jira login
Enter Password for user01:

C:\Users\user01
λ jira issuetypes
Request:
Incident:
Sub-task:     The sub-task of the issue
Project:
Epic:         Created by JIRA Agile - do not edit or delete. Issue type for a big user story that needs to be broken down.
Task:         A task that needs to be done.

C:\Users\user01
λ jira create -i Task
2016-06-29T20:51:18.200-05:00 ERROR [cli.go:268] Failed to rename C:\Users\user01\.jira.d\tmp\create-task-063183995 to C:\Users\user01\.jira.d\tmp\create-task-063183995.yml: 
  rename C:\Users\user01\.jira.d\tmp\create-task-063183995 C:\Users\user01\.jira.d\tmp\create-task-063183995.yml: 
  The process cannot access the file because it is being used by another process.
2016-06-29T20:51:18.225-05:00 ERROR [main.go:455] rename C:\Users\user01\.jira.d\tmp\create-task-063183995 C:\Users\user01\.jira.d\tmp\create-task-063183995.yml: 
  The process cannot access the file because it is being used by another process.

I believe this is related to a GO function os.Rename() that has had some debate about functioning on Windows and POSIX systems.

Here are the links to the Code Line Numbers from the errors. The main.go error is just the error check, and I linked the create case statement.

Once again though, still working on the learning GO thing, so hopefully I can pitch in soon.

@coryb
Copy link
Contributor

coryb commented Jun 30, 2016

Thanks for the report. Interesting. I don't think this has to do with issue you linked to, at least we are not trying to overwrite a file that already exists.

I think the problem is that go-jira has a tmp file open, then tries to rename that file, which apparently seems to be forbidden on windows resulting in:

The process cannot access the file because it is being used by another process

The goal of the code is to create a tmp file with a known file extension (ie .yml) that will tell editors to use yaml editing mode, the Go TempFile routine does not let you specify the file extension. So we create the file (which also opens it) then try to rename the file while still open.

I think the "work around" would be to just close the file, move it, then reopen it.

coryb added a commit that referenced this issue Jun 30, 2016
…access the file because it is being used by another process" error on windows.
@coryb
Copy link
Contributor

coryb commented Jun 30, 2016

I have published a new release with my work around, which seems to work with my limited testing . Please try it out, downloads here: https://github.com/Netflix-Skunkworks/go-jira/releases/tag/v0.1.2

@FilBot3
Copy link
Author

FilBot3 commented Jun 30, 2016

Cool, this is working now, just need to figure out the fields bit in the YAML, seems some fields in our Jira instance are uneditable.

@coryb
Copy link
Contributor

coryb commented Jun 30, 2016

Yeah, the fields are fussy because Jira allows so much customization. reporter is commonly not allowed to be updated, and the others likely depend on the customizations to your project type and issue type. The error messages after posting the issue to Jira should tell you what fields are not allowed. When you figure out what works then you can modify the template and put it in %USERPROFILE%\.jira.d\templates\create.yml so then go-jira will use that template in the future.

@coryb
Copy link
Contributor

coryb commented Jun 30, 2016

closing this issue.

@coryb coryb closed this as completed Jun 30, 2016
pdericson pushed a commit to pdericson/go-jira that referenced this issue Sep 14, 2017
…cannot access the file because it is being used by another process" error on windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants