config icon indicating copy to clipboard operation
config copied to clipboard

YAML error: found character that cannot start any token

Open stephanos opened this issue 11 years ago • 110 comments

Maybe I'm doing something wrong, but when I parse this file:

smtp:
    port: 25
    host: smtp.mail.com
    username: johndoe
    password: secretpassword

with

config.ParseYaml(configData)

I get

YAML error: line 1: found character that cannot start any token

stephanos avatar Jun 03 '13 11:06 stephanos

Check if you are using tabs for indentation. YAML doesn't allow tabs; it requires spaces.

moraes avatar Jun 03 '13 13:06 moraes

This is a year late, but... thank you moraes, you solved my issue. :)

egeersoz avatar Apr 17 '14 00:04 egeersoz

Mine too ;)

aeneasr avatar Jun 02 '15 12:06 aeneasr

Doh

wader avatar Aug 01 '15 21:08 wader

Glad I'm not the only one here overlooking simple things, thanks @moraes

brendangibat avatar Oct 06 '15 14:10 brendangibat

So helpful.

JulianKingman avatar Oct 19 '15 19:10 JulianKingman

Looks like YAML syntax should be reconsidered..

aeneasr avatar Oct 19 '15 19:10 aeneasr

:+1:

34code avatar Feb 06 '16 19:02 34code

And I wondered whole fu**ing day why does Vim replace tabs with spaces when I edit yaml... :D

nemanjan00 avatar Feb 07 '16 14:02 nemanjan00

Thanks

kevingo avatar May 27 '16 05:05 kevingo

Thanks. 👍

rishiloyola avatar May 27 '16 07:05 rishiloyola

Thanks a lot! Took me half a day to resolve this issue.

jealous avatar Aug 11 '16 10:08 jealous

Simple but strong. Helped me too.

odravison avatar Sep 09 '16 03:09 odravison

it helped me as well :)

RohithChandran avatar Feb 03 '17 03:02 RohithChandran

it helps me too

kehao95 avatar Mar 02 '17 08:03 kehao95

found character '' that cannot start any token - pwd`/auth:/usr/local/apache2/conf

tomachinz avatar Apr 03 '17 11:04 tomachinz

Thanks

ezhiliamplus avatar Apr 07 '17 14:04 ezhiliamplus

👍 Saving the day!

bahramkarimi avatar Apr 27 '17 11:04 bahramkarimi

ahah yup! one more! thanks man :)

bitfede avatar May 09 '17 16:05 bitfede

thanks!!

yusuken-freee avatar Aug 04 '17 05:08 yusuken-freee

me too~ thanks

tedqian avatar Aug 10 '17 05:08 tedqian

thanks!!

multiarts avatar Aug 12 '17 00:08 multiarts

Thank you

dancwilliams avatar Sep 24 '17 12:09 dancwilliams

Thank you, savior.

rohitpujar avatar Oct 01 '17 18:10 rohitpujar

Big thx) -

WiRight avatar Oct 20 '17 20:10 WiRight

Thanks much. :)

rotelando avatar Oct 30 '17 09:10 rotelando

And my axe! Solved my issue!

ghost avatar Nov 06 '17 17:11 ghost

thanks!

daveyman123 avatar Nov 15 '17 01:11 daveyman123

Same here. Thanks If you use VIM,

set list
set listchars=tab:>-

will find those busters

yahavb avatar Dec 01 '17 06:12 yahavb

Had the same problem with menus. Was using tabs (as per the video I was watching). Changing to spaces solved it. Thank you.

boggled-mind avatar Jan 10 '18 16:01 boggled-mind

Thanks a lot !

Tchuuu avatar Feb 11 '18 01:02 Tchuuu

A great day must be remembered!!! Thank you!

LingyunSu avatar Feb 15 '18 18:02 LingyunSu

Thanks so much!!!! I've spent too much time on finding any spelling error T_T

sukizuo avatar Mar 09 '18 08:03 sukizuo

I have just used 4 space to indent got the same error. Please guide me where I am wrong.

Akash187 avatar Mar 24 '18 18:03 Akash187

@Akash187 you sure it's spaces, maybe your editor does some smartness on save etc? if your unsure have a look with hexdump -C etc

wader avatar Mar 24 '18 18:03 wader

thanks a lot! saved a lot of time.

kollipara avatar Apr 10 '18 16:04 kollipara

Thanks a lot @moraes

dapseen avatar Apr 19 '18 15:04 dapseen

+1 for the Thanks a lot section :grinning:

zpalazov avatar Apr 23 '18 13:04 zpalazov

+1 for the Thanks a lot

reddish-purple-ocelot avatar Apr 25 '18 17:04 reddish-purple-ocelot

+1 Thanks !!!

varunchandak avatar Apr 30 '18 08:04 varunchandak

+1 Thanks a lot, :)

eundoosong avatar May 10 '18 10:05 eundoosong

Thanks!!!

law-lee avatar May 23 '18 02:05 law-lee

5 years later and moares comment saved my ass.

patricf avatar Jul 19 '18 13:07 patricf

Saved my day... 5yrs later

nickchacha avatar Jul 28 '18 14:07 nickchacha

Thank you so so much.

dibya001 avatar Aug 21 '18 06:08 dibya001

Found this when trying to config a bond network interface under Ubuntu 18.04 for HOURS! yaml and netplan SUCK!! The old plain style in /etc/network/interfaces worked for decades, and now we all need something new? What a waste of lifetime!

der-stefan avatar Sep 19 '18 19:09 der-stefan

Damn. Thank you so much man. Cheers. :smile:

adamhtoolwin avatar Sep 21 '18 14:09 adamhtoolwin

Yup, still useful knowledge.

psaxton avatar Oct 10 '18 20:10 psaxton

@Akash187 you sure it's spaces, maybe your editor does some smartness on save etc? if your unsure have a look with hexdump -C etc

Thank you @Akash187 Your comment saved me a lot of pain. Nano left some tabs below where I was editing, flushed it, cleaned it, and it's now working!

Old-Nerd avatar Nov 01 '18 04:11 Old-Nerd

Mine too ;)

AksHuge avatar Nov 05 '18 06:11 AksHuge

我也是,就是tab缩进的问题

LLLLLLW avatar Nov 10 '18 08:11 LLLLLLW

great!

abdennour avatar Dec 01 '18 03:12 abdennour

few years later... :) Big Thanks.. @moraes ...... I scratched my head for hours over this one, because I explicitly set my editor for tab == 2 spaces, never thought that could be a problem hehe

Goku-San avatar Dec 04 '18 09:12 Goku-San

Watch for trailing lines at the end of the file - a tab there breaks things too

gherlein avatar Dec 08 '18 00:12 gherlein

Tried removing the space but still got the same error.

Deleted the file and created a new one with same stuff ... worked for me.

Added for reference :)

ankyjk avatar Jan 25 '19 06:01 ankyjk

Came here for the same issue on a totally unrelated project and this saved my day: thanks @moraes!

claudiodangelis avatar May 08 '19 17:05 claudiodangelis

find tabs across all yaml files in current dir recursively : grep -rn --include=*.{yaml,yml} "\t" ./

dmitrytokarev avatar May 21 '19 21:05 dmitrytokarev

Thank you.

Sushmeet avatar May 25 '19 01:05 Sushmeet

Thank you!

kassavage avatar May 28 '19 13:05 kassavage

Check if you are using tabs for indentation. YAML doesn't allow tabs; it requires spaces.

6 years after your answer, you solved my issue. Thank you

abenzakour avatar Jul 27 '19 18:07 abenzakour

@moraes Greatly appreciated! @nemanjan00 weird, cause my Vim didn't do it, and that's how I ended up here :)

andriimakarenko avatar Sep 04 '19 22:09 andriimakarenko

Sounds like you need to take a look at my dotfiles

nemanjan00 avatar Sep 05 '19 01:09 nemanjan00

@nemanjan00 actually not. I wrote a Vim plugin for myself a while ago and forgot the nuances of what exactly it does. Turns out, among other things it replaces spaces with hard tabs, and I forgot it does. So it either undoes what Vim does by default or just overrides it.

Anyways, your config is really nice, especially the bottom stripe, it's much more informative than the one I got. Thank you for sharing it!

andriimakarenko avatar Sep 05 '19 07:09 andriimakarenko

5 Years later still helping people (myself included) !

mmihira avatar Sep 30 '19 03:09 mmihira

Thanks :)

heyitsmekishore avatar Oct 16 '19 06:10 heyitsmekishore

@moraes it seems to me that tab is actually an valid character in yaml by the spec https://yaml.org/spec/1.2/spec.html , see section 5.5. White Space Characters

flyfy1 avatar Dec 20 '19 09:12 flyfy1

Lol this is such a great post, I had no idea why my site wasn't rendering and I just re wrote it! I made sure there were no tabs and it worked! 6.5 years later still relevant!

AmitLevinson avatar Jan 08 '20 22:01 AmitLevinson

@moraes Dude you are awesome

sagespidy avatar Feb 04 '20 14:02 sagespidy

@moraes Thanks man /| Never too late :)

srinathln7 avatar Mar 03 '20 10:03 srinathln7

@moraes one more lol thanks

st-f avatar Mar 03 '20 19:03 st-f

@moraes thx from 2020 :)

VitaliiLototskyi avatar Mar 10 '20 17:03 VitaliiLototskyi

thanks!

sijanec avatar Mar 27 '20 22:03 sijanec

I'm going to unsubscribe this issue. My email inbox is already full. hahahaha

odravison avatar Mar 28 '20 12:03 odravison

thanks!

JourneyWoo avatar Apr 15 '20 20:04 JourneyWoo

Thank you!!!!!

arthuralvaresbandtec avatar Apr 23 '20 18:04 arthuralvaresbandtec

@moraes Thank you very much, while googling I got this link, I was struck with this from last 2 days, With your one line comment i solved my issues in deployment file, Application running in AKS now, Thank you very much, Great information never gets older:)

radhegithub avatar Apr 25 '20 12:04 radhegithub

This issue cost me for an hour!

Thank you!!! I feel better now!

IEB-Richard avatar May 01 '20 05:05 IEB-Richard

Well, I had a problem with a variable containing @ character at the start. Fixed by | quote

defusioner avatar Jun 23 '20 07:06 defusioner

Cheers bud

pmgexpo17 avatar Jun 26 '20 00:06 pmgexpo17

7 years after your answer, you saved my time. Thank you

ykfq avatar Jul 18 '20 12:07 ykfq

works for me, thanks!!!

NewHongjayGitHub avatar Sep 15 '20 01:09 NewHongjayGitHub

Thank you, I had some evil tabs. You saved me a lot of hair-pulling.

Zorlin avatar Sep 16 '20 04:09 Zorlin

@moraes, Dude, Thank you. Saved my day!.

baksharp avatar Oct 21 '20 05:10 baksharp

Thanks !!! Solved my headache

amjack0 avatar Dec 17 '20 13:12 amjack0

Same here. Thanks If you use VIM,

set list
set listchars=tab:>-

will find those busters

Thanks !

admsys-probox avatar Feb 12 '21 11:02 admsys-probox

Nano users don't have this problem, because mixed tabs/spaces show in red. But they have other problems.

sijanec avatar Feb 12 '21 12:02 sijanec

Solved my issue too !! thanks

post2tr avatar Feb 15 '21 19:02 post2tr

Thank you!

wlabatey avatar Apr 27 '21 06:04 wlabatey

Thank you!!

misskecupbung avatar Jun 26 '21 21:06 misskecupbung

This is madness!

HalidCisse avatar Jul 02 '21 19:07 HalidCisse

Check if you are using tabs for indentation. YAML doesn't allow tabs; it requires spaces.

This post is the defacto google answer for that error. Thanks for that. Besides that, if the error message has gotten a little bit more love, we could all saved 5 mins of our life :D

DavidLambauer avatar Sep 28 '21 09:09 DavidLambauer

This helped me a lot. Thank you!

CousinOkri avatar Oct 21 '21 08:10 CousinOkri

I don't know how but a wild tab appeard in the config.

Thanks

Jonakss avatar Dec 22 '21 17:12 Jonakss

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

LLLLLLW avatar Dec 22 '21 17:12 LLLLLLW

Thank you .. saved my day

hananint avatar Jan 19 '22 16:01 hananint

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

LLLLLLW avatar Jan 19 '22 16:01 LLLLLLW

Best answer ever! :)

chboris avatar Feb 03 '22 15:02 chboris

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

LLLLLLW avatar Feb 03 '22 15:02 LLLLLLW

9 years later: Here I am, saying thank you as well :D

livia-ohman avatar Feb 10 '22 15:02 livia-ohman

Yep, happened to me today. Thank you.

brneor avatar Feb 10 '22 21:02 brneor