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

task config does not report an error if it cannot write to .taskrc #3611

Open
echo-bravo-yahoo opened this issue Aug 29, 2024 · 13 comments
Open
Labels
type:bug Something isn't working

Comments

@echo-bravo-yahoo
Copy link

echo-bravo-yahoo commented Aug 29, 2024

~ ❯ task context define test project:personal
Are you sure you want to add 'context.test.read' with a value of 'project:personal'? (yes/no) y
Are you sure you want to add 'context.test.write' with a value of 'project:personal'? (yes/no) y
Context 'test' defined (read, write). Use 'task context test' to activate.
~ ❯ task context test
Context 'test' not found.
~ ❯ task context list | grep test
~ ❯ task context delete test
Do you want to delete context 'test'? (yes/no) y
Context 'test' not found.
~ ❯ task --version
3.1.0
~ ❯ task diag
task 3.1.0
   Platform: Darwin

Compiler
    Version: Apple LLVM 15.0.0 (clang-1500.3.9.4)
       Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
 Compliance: C++17

Build Features
      CMake: 3.30.2
    libuuid: libuuid + uuid_unparse_lower
 Build type: Release

Configuration
       File: /Users/.../.taskrc (found), 5192 bytes, mode 100644
       Data: /Users/.../.task (found), dir, mode 40755
         GC: Enabled
    $EDITOR: nvim
Hooks
     System: Disabled
   Location: /Users/.../.task/hooks
             (-none-)

Tests
   Terminal: 416x114
 Broken ref: Scanned 2814 tasks for broken references:
             No broken references found
~ ❯ vim ~/.taskrc
~ ❯ task context list | grep manualtest
manualtest         read  project:personal                                       no
~ ❯ task context delete manualtest
Do you want to delete context 'manualtest'? (yes/no) yes
Context 'manualtest' deleted.
~ ❯ task context list | grep manualtest
~ ❯ 

I don't appear to be able to create contexts in v3.1.0 from the CLI. Some other useful information:

  • I recently upgraded to taskwarrior v3
  • I'm using taskchampion-server to sync
  • I have many old-style contexts (read only) in my task rc and no new-style contexts
    • I actually can't find any migration docs - what sent me down this rabbit hole in the first place was wanting to migrate my contexts to the newer definition style
@djmitche
Copy link
Collaborator

I don't know much about contexts, but this does work for me. As the vim ~/.taskrc suggests, task context define just adds some lines to .taskrc. Is it not adding them, or are they not being interpreted correctly?

@echo-bravo-yahoo
Copy link
Author

echo-bravo-yahoo commented Aug 30, 2024

They were not being added (despite the command exiting successfully). I can't reproduce on this computer, will try again tonight on the other computer. I did end up making this tiny test harness, though, that might be helpful for some people to generate minimal repros:

mkdir ~/.task-debug && \
echo -e "data.location=~/.task-debug\nnews.version=3.1.0" >> ~/.taskrc-debug && \
TASKRC=~/.taskrc-debug task list

@djmitche
Copy link
Collaborator

Is the .taskrc writeable? I see a link to #3613 where .taskrc appears to be read-only, so worth asking.

If the .taskrc modification fails silently, that would be a bug!

I actually can't find any migration docs - what sent me down this rabbit hole in the first place was wanting to migrate my contexts to the newer definition style

I didn't realize there was any migration to do. What is the "older definition style"? As I said, I don't know much about contexts!

@djmitche
Copy link
Collaborator

       File: /Users/.../.taskrc (found), 5192 bytes, mode 100644

I can't figure out what that 1 means. It's not in chmod(2) on my system..

@echo-bravo-yahoo
Copy link
Author

So, "old" contexts look like:

context.home=project:home

Taskwarrior appears to convert this internally to a "new" context with only its read behavior defined:

context.home.read=project:home
context.home.write=

If I wanted newly-created tasks in this context to have certain properties, I could edit it to be:

context.home.read=project:home
context.home.write=project:home priority:L

This isn't really documented anywhere I could find, so I've sort of sussed this out from interacting with it on several computers with several versions of taskwarrior.

@echo-bravo-yahoo
Copy link
Author

Maybe this is a WSL/linux permission intersection issue? The computer that was not behaving well was ubuntu-in-windows; maybe @martiege has a similar setup?

@djmitche
Copy link
Collaborator

Oh, intersting --

    Version: Apple LLVM 15.0.0 (clang-1500.3.9.4)

had me assuming this was a mac..

A PR to add documentation for those formats, either to the manpages here, or to https://github.com/GothenburgBitFactory/tw.org, would be great!

@echo-bravo-yahoo
Copy link
Author

Ah, sorry - I recently migrated to taskwarrior 3 on a linux computer, a WSL computer, a mac, and an android phone, and the issues I was having were either on the mac or the WSL computer, but neither are reproducible now (I just checked the WSL setup, and it's working fine) and I grabbed the logs from the mac.

This is especially perplexing because I version control my taskrc, and I rolled it backwards/forwards and couldn't get it to repro at any recent commit...

@echo-bravo-yahoo
Copy link
Author

echo-bravo-yahoo commented Aug 30, 2024

I think this issue can probably be closed for now (can't repro, can't fix, and i'm unblocked). I'll take a look at the docs site for contexts and see if I can get a PR up sometime soon. Thanks!

~/w/wildflower/valley main !2 ❯ ls -la ~/.taskrc
-rw-r--r-- 1 foo foo 5192 Aug 30 16:06 /home/foo/.taskrc
~/w/wildflower/valley main !2 ❯ chmod -w ~/.taskrc
~/w/wildflower/valley main !2 ❯ t context define test +test
Are you sure you want to add 'context.test.read' with a value of '+test'? (yes/no) y
Are you sure you want to add 'context.test.write' with a value of '+test'? (yes/no) y
Context 'test' defined (read, write). Use 'task context test' to activate.
~/w/wildflower/valley main !2 ❯ echo $?
0
~/w/wildflower/valley main !2 ❯ t context test
Context 'test' not found.
~/w/wildflower/valley main !2 ❯ chmod +w ~/.taskrc
~/w/wildflower/valley main !2 ❯ t context define test +test
Are you sure you want to add 'context.test.read' with a value of '+test'? (yes/no) y
Are you sure you want to add 'context.test.write' with a value of '+test'? (yes/no) y
Context 'test' defined (read, write). Use 'task context test' to activate.
~/w/wildflower/valley main !2 ❯ t context test
Context 'test' set. Use 'task context none' to remove.

Ok, so there definitely is a "fails silently" bug here. figured since the repro was easy enough i'd test it, and sure enough... :)

@djmitche
Copy link
Collaborator

OK, nice! I can repro that too, with the simpler task config:

⸩ chmod -w .taskrc
⸩ echo foo=bar >> .taskrc 
bash: .taskrc: Permission denied
⸩ task config foo bar
Are you sure you want to add 'foo' with a value of 'bar'? (yes/no) yes
TASKRC override: /home/dustin/p/taskwarrior/.taskrc
Config file /home/dustin/p/taskwarrior/.taskrc modified.
⸩ grep foo= .taskrc 
⸩ 

I'll mark this as a bug and add it to the backlog.

@djmitche djmitche changed the title Context creation broken in taskwarrior 3.1.0 task config does not report an error if it cannot write to .taskrc Aug 30, 2024
@djmitche djmitche added the type:bug Something isn't working label Aug 30, 2024
@martiege
Copy link

martiege commented Aug 31, 2024

@echo-bravo-yahoo it might be related yeah, as I only seem to experience the issue when I include a symlinked and read-only file, though I'm running nixos natively and not through wsl or anything. I'll check what permissions are given, but it still seems strange to me that the behaviour seems so random.

@gagankonana
Copy link
Contributor

I raised a PR to address silent fails on modification of the .taskrc file.

@djmitche
Copy link
Collaborator

Thanks @gagankonana.

@martiege or @echo-bravo-yahoo, do you have the capability to compile locally and verify that @gagankonana's fix has addressed the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

4 participants