ざるを得ない・ないわけにはいかない・しかない: the difference
ざるを得ないN2
Meaning
Can't help doing, Have no choice but
Past papers
Tested 3 times in past papers
Example
サプライズのプレゼントに、驚かざるを得なかった。
I couldn't help but be surprised at the surprise present.
Meaning
Can't not, No way to avoid
Past papers
Tested once in past papers
Example
訳あって、白髪を染めないわけにはいかないんです。
For certain reasons, I can't leave my gray hair undyed.
しかないN3
Meaning
Have no choice but to, Can only
Past papers
Tested 3 times in past papers
Example
人が多いから、並ぶしかない。
Because there are a lot of people, we have no choice but to line up.
How to tell them apart
「ないわけにはいかない」: you can't skip it because of duty or common sense.
「しかない」: there is no other way; common in speech.
「ざるを得ない」: unwilling, but forced by circumstances; heavy and written in tone.